chromium/chrome/common/channel_info_unittest.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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  // BUILDFLAG(GOOGLE_CHROME_BRANDING)

namespace chrome {

namespace {

// A bucket of test parameters for ChannelInfoTest.
struct Param {};

}  // namespace

// A value-parameterized test to facilitate testing the various channel info
// functions. Branded builds evaluate all tests once for each supported channel.
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 the test suite once per supported channel in branded builds.
INSTANTIATE_TEST_SUITE_P(
    Stable,
    ChannelInfoTest,
    ::testing::Values(Param(ScopedChannelOverride::Channel::kStable,
                            "",
                            "",
                            version_info::Channel::STABLE,
                            /*is_extended_stable=*/false,
                            /*posix_data_dir_suffix=*/"")));
INSTANTIATE_TEST_SUITE_P(
    ExtendedStable,
    ChannelInfoTest,
    ::testing::Values(Param(ScopedChannelOverride::Channel::kExtendedStable,
                            "",
                            "extended",
                            version_info::Channel::STABLE,
                            /*is_extended_stable=*/true,
                            /*posix_data_dir_suffix=*/"")));
INSTANTIATE_TEST_SUITE_P(
    Beta,
    ChannelInfoTest,
    ::testing::Values(Param(ScopedChannelOverride::Channel::kBeta,
                            "beta",
                            "beta",
                            version_info::Channel::BETA,
                            /*is_extended_stable=*/false,
                            /*posix_data_dir_suffix=*/"-beta")));
INSTANTIATE_TEST_SUITE_P(
    Dev,
    ChannelInfoTest,
    ::testing::Values(Param(ScopedChannelOverride::Channel::kDev,
                            "dev",
                            "dev",
                            version_info::Channel::DEV,
                            /*is_extended_stable=*/false,
                            /*posix_data_dir_suffix=*/"-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,
                            /*is_extended_stable=*/false,
                            /*posix_data_dir_suffix=*/"")));
#endif  // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)  ||
        // BUILDFLAG(IS_LINUX)
#else   // BUILDFLAG(GOOGLE_CHROME_BRANDING)
INSTANTIATE_TEST_SUITE_P();
#endif  // BUILDFLAG(GOOGLE_CHROME_BRANDING)

}  // namespace chrome