#include "chrome/common/channel_info.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/version_info/channel.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
#include "chrome/test/base/scoped_channel_override.h"
#endif
namespace chrome {
namespace {
struct Param { … };
}
class ChannelInfoTest : public ::testing::TestWithParam<Param> { … };
TEST_P(ChannelInfoTest, GetVersionStringWithout) { … }
TEST_P(ChannelInfoTest, GetVersionStringWith) { … }
TEST_P(ChannelInfoTest, GetChannelNameWithout) { … }
TEST_P(ChannelInfoTest, GetChannelNameWith) { … }
TEST_P(ChannelInfoTest, GetChannel) { … }
TEST_P(ChannelInfoTest, IsExtendedStableChannel) { … }
#if BUILDFLAG(IS_WIN)
#elif BUILDFLAG(IS_MAC)
TEST_P(ChannelInfoTest, GetChannelByName) {
EXPECT_EQ(GetChannelByName(GetParam().channel_name_with_es),
GetParam().channel);
}
#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
TEST_P(ChannelInfoTest, GetChannelSuffixForDataDir) { … }
#endif
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
INSTANTIATE_TEST_SUITE_P(
Stable,
ChannelInfoTest,
::testing::Values(Param(ScopedChannelOverride::Channel::kStable,
"",
"",
version_info::Channel::STABLE,
false,
"")));
INSTANTIATE_TEST_SUITE_P(
ExtendedStable,
ChannelInfoTest,
::testing::Values(Param(ScopedChannelOverride::Channel::kExtendedStable,
"",
"extended",
version_info::Channel::STABLE,
true,
"")));
INSTANTIATE_TEST_SUITE_P(
Beta,
ChannelInfoTest,
::testing::Values(Param(ScopedChannelOverride::Channel::kBeta,
"beta",
"beta",
version_info::Channel::BETA,
false,
"-beta")));
INSTANTIATE_TEST_SUITE_P(
Dev,
ChannelInfoTest,
::testing::Values(Param(ScopedChannelOverride::Channel::kDev,
"dev",
"dev",
version_info::Channel::DEV,
false,
"-unstable")));
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
INSTANTIATE_TEST_SUITE_P(
Canary,
ChannelInfoTest,
::testing::Values(Param(ScopedChannelOverride::Channel::kCanary,
"canary",
"canary",
version_info::Channel::CANARY,
false,
"")));
#endif
#else
INSTANTIATE_TEST_SUITE_P(…);
#endif
}