Fix MetricsUtilTest.DefaultValueTest on origin builds (#35388)
The test expected GetDefaultPrefValueForMetricsReporting() to return
true for beta/dev/nightly channels, but on origin-branded builds the
function unconditionally returns false (added in 2d48fb7f59). Update
the test expectations to account for IS_BRAVE_ORIGIN_BRANDED.
Resolves brave/brave-browser#54242
This commit is contained in:
@@ -45,6 +45,7 @@ source_set("brave_metrics_unit_tests") {
|
||||
configs += [ "//brave/build/linux:linux_channel_names" ]
|
||||
|
||||
deps += [
|
||||
"//brave/components/brave_origin/buildflags",
|
||||
"//chrome/common:channel_info",
|
||||
"//components/version_info:channel",
|
||||
]
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/metrics/metrics_reporting_util.h"
|
||||
|
||||
#include "base/environment.h"
|
||||
#include "brave/browser/metrics/metrics_reporting_util.h"
|
||||
#include "brave/components/brave_origin/buildflags/buildflags.h"
|
||||
#include "chrome/common/channel_info.h"
|
||||
#include "components/version_info/channel.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@@ -20,15 +20,27 @@ TEST(MetricsUtilTest, DefaultValueTest) {
|
||||
|
||||
env->SetVar("CHROME_VERSION_EXTRA", LINUX_CHANNEL_BETA);
|
||||
EXPECT_EQ(version_info::Channel::BETA, chrome::GetChannel());
|
||||
#if BUILDFLAG(IS_BRAVE_ORIGIN_BRANDED)
|
||||
EXPECT_FALSE(GetDefaultPrefValueForMetricsReporting());
|
||||
#else
|
||||
EXPECT_TRUE(GetDefaultPrefValueForMetricsReporting());
|
||||
#endif
|
||||
|
||||
env->SetVar("CHROME_VERSION_EXTRA", LINUX_CHANNEL_DEV);
|
||||
EXPECT_EQ(version_info::Channel::DEV, chrome::GetChannel());
|
||||
#if BUILDFLAG(IS_BRAVE_ORIGIN_BRANDED)
|
||||
EXPECT_FALSE(GetDefaultPrefValueForMetricsReporting());
|
||||
#else
|
||||
EXPECT_TRUE(GetDefaultPrefValueForMetricsReporting());
|
||||
#endif
|
||||
|
||||
env->SetVar("CHROME_VERSION_EXTRA", BRAVE_LINUX_CHANNEL_NIGHTLY);
|
||||
EXPECT_EQ(version_info::Channel::CANARY, chrome::GetChannel());
|
||||
#if BUILDFLAG(IS_BRAVE_ORIGIN_BRANDED)
|
||||
EXPECT_FALSE(GetDefaultPrefValueForMetricsReporting());
|
||||
#else
|
||||
EXPECT_TRUE(GetDefaultPrefValueForMetricsReporting());
|
||||
#endif
|
||||
#else // OFFICIAL_BUILD
|
||||
EXPECT_EQ(version_info::Channel::UNKNOWN, chrome::GetChannel());
|
||||
EXPECT_FALSE(GetDefaultPrefValueForMetricsReporting());
|
||||
|
||||
Reference in New Issue
Block a user