diff options
author | Victor-Gabriel Savu <vsavu@google.com> | 2023-03-22 10:15:16 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-28 12:55:32 +0000 |
commit | 5decca203f7efe4035d99400cad10ec2d922df4c (patch) | |
tree | 81d32e56466861d80cdbd0efdc0d016d22941d6f | |
parent | f14d819aaa870a208c2f12fde7698fbb28fcf2c2 (diff) | |
download | update_engine-5decca203f7efe4035d99400cad10ec2d922df4c.tar.gz |
update_engine: Use constants for the channels
Use constants for the channels and replace all strings in the
repository.
BUG=None
TEST=update_engine unit tests
Change-Id: Ibb84c6deefec1fab6181f150f358b99e8b8a2d8a
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/4359654
Tested-by: Victor-Gabriel Savu <vsavu@google.com>
Commit-Queue: Victor-Gabriel Savu <vsavu@google.com>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
-rw-r--r-- | common/constants.h | 8 | ||||
-rw-r--r-- | cros/common_service_unittest.cc | 12 | ||||
-rw-r--r-- | cros/image_properties_chromeos.cc | 4 | ||||
-rw-r--r-- | cros/image_properties_chromeos_unittest.cc | 16 | ||||
-rw-r--r-- | cros/omaha_request_action_unittest.cc | 10 | ||||
-rw-r--r-- | cros/omaha_request_params.cc | 22 | ||||
-rw-r--r-- | cros/omaha_request_params_unittest.cc | 96 | ||||
-rw-r--r-- | cros/omaha_response_handler_action_unittest.cc | 32 | ||||
-rw-r--r-- | cros/update_attempter_unittest.cc | 4 | ||||
-rw-r--r-- | update_manager/enterprise_device_policy_impl_unittest.cc | 5 |
10 files changed, 108 insertions, 101 deletions
diff --git a/common/constants.h b/common/constants.h index c3dac63f..2a3cdcb6 100644 --- a/common/constants.h +++ b/common/constants.h @@ -235,6 +235,14 @@ const int kSHA256Size = 32; // Limit on the number of consecutive updates. const int64_t kConsecutiveUpdateLimit = 3; +// Channel constants. +constexpr const char kCanaryChannel[] = "canary-channel"; +constexpr const char kDevChannel[] = "dev-channel"; +constexpr const char kBetaChannel[] = "beta-channel"; +constexpr const char kStableChannel[] = "stable-channel"; +constexpr const char kLtcChannel[] = "ltc-channel"; +constexpr const char kLtsChannel[] = "lts-channel"; + } // namespace chromeos_update_engine #endif // UPDATE_ENGINE_COMMON_CONSTANTS_H_ diff --git a/cros/common_service_unittest.cc b/cros/common_service_unittest.cc index 70a443a8..a5cb81a9 100644 --- a/cros/common_service_unittest.cc +++ b/cros/common_service_unittest.cc @@ -129,9 +129,9 @@ TEST_F(UpdateEngineServiceTest, SetChannelWithNoPolicy) { EXPECT_CALL(*mock_update_attempter_, RefreshDevicePolicy()); // If SetTargetChannel is called it means the policy check passed. EXPECT_CALL(*FakeSystemState::Get()->mock_request_params(), - SetTargetChannel("stable-channel", true, _)) + SetTargetChannel(kStableChannel, true, _)) .WillOnce(Return(true)); - EXPECT_TRUE(common_service_.SetChannel(&error_, "stable-channel", true)); + EXPECT_TRUE(common_service_.SetChannel(&error_, kStableChannel, true)); ASSERT_EQ(nullptr, error_); } @@ -142,10 +142,10 @@ TEST_F(UpdateEngineServiceTest, SetChannelWithDelegatedPolicy) { EXPECT_CALL(mock_device_policy, GetReleaseChannelDelegated(_)) .WillOnce(DoAll(SetArgPointee<0>(true), Return(true))); EXPECT_CALL(*FakeSystemState::Get()->mock_request_params(), - SetTargetChannel("beta-channel", true, _)) + SetTargetChannel(kBetaChannel, true, _)) .WillOnce(Return(true)); - EXPECT_TRUE(common_service_.SetChannel(&error_, "beta-channel", true)); + EXPECT_TRUE(common_service_.SetChannel(&error_, kBetaChannel, true)); ASSERT_EQ(nullptr, error_); } @@ -167,7 +167,7 @@ TEST_F(UpdateEngineServiceTest, SetChannelWithInvalidChannel) { TEST_F(UpdateEngineServiceTest, SetChannelWithCommercialChannelLts) { EXPECT_CALL(*mock_update_attempter_, RefreshDevicePolicy()); - EXPECT_FALSE(common_service_.SetChannel(&error_, "lts-channel", true)); + EXPECT_FALSE(common_service_.SetChannel(&error_, kLtsChannel, true)); ASSERT_NE(nullptr, error_); EXPECT_TRUE(error_->HasError(UpdateEngineService::kErrorDomain, UpdateEngineService::kErrorFailed)); @@ -177,7 +177,7 @@ TEST_F(UpdateEngineServiceTest, SetChannelWithCommercialChannelLts) { TEST_F(UpdateEngineServiceTest, SetChannelWithCommercialChannelLtc) { EXPECT_CALL(*mock_update_attempter_, RefreshDevicePolicy()); - EXPECT_FALSE(common_service_.SetChannel(&error_, "ltc-channel", true)); + EXPECT_FALSE(common_service_.SetChannel(&error_, kLtcChannel, true)); ASSERT_NE(nullptr, error_); EXPECT_TRUE(error_->HasError(UpdateEngineService::kErrorDomain, UpdateEngineService::kErrorFailed)); diff --git a/cros/image_properties_chromeos.cc b/cros/image_properties_chromeos.cc index 2e159f09..5e06242c 100644 --- a/cros/image_properties_chromeos.cc +++ b/cros/image_properties_chromeos.cc @@ -94,7 +94,7 @@ ImageProperties LoadImageProperties() { brillo::KeyValueStore lsb_release; LoadLsbRelease(LsbReleaseSource::kSystem, &lsb_release); result.current_channel = GetStringWithDefault( - lsb_release, kLsbReleaseUpdateChannelKey, "stable-channel"); + lsb_release, kLsbReleaseUpdateChannelKey, kStableChannel); // In dev-mode and unofficial build we can override the image properties set // in the system image with the ones from the stateful partition, except the @@ -134,7 +134,7 @@ MutableImageProperties LoadMutableImageProperties() { LoadLsbRelease(LsbReleaseSource::kSystem, &lsb_release); LoadLsbRelease(LsbReleaseSource::kStateful, &lsb_release); result.target_channel = GetStringWithDefault( - lsb_release, kLsbReleaseUpdateChannelKey, "stable-channel"); + lsb_release, kLsbReleaseUpdateChannelKey, kStableChannel); if (!lsb_release.GetBoolean(kLsbReleaseIsPowerwashAllowedKey, &result.is_powerwash_allowed)) result.is_powerwash_allowed = false; diff --git a/cros/image_properties_chromeos_unittest.cc b/cros/image_properties_chromeos_unittest.cc index 497554e2..4f91d29f 100644 --- a/cros/image_properties_chromeos_unittest.cc +++ b/cros/image_properties_chromeos_unittest.cc @@ -64,7 +64,7 @@ TEST_F(ImagePropertiesTest, SimpleTest) { EXPECT_EQ("arm-generic", props.board); EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", props.product_id); EXPECT_EQ("0.2.2.3", props.version); - EXPECT_EQ("dev-channel", props.current_channel); + EXPECT_EQ(kDevChannel, props.current_channel); EXPECT_EQ("http://www.google.com", props.omaha_url); } @@ -104,10 +104,10 @@ TEST_F(ImagePropertiesTest, OverrideTest) { "CHROMEOS_AUSERVER=https://www.google.com")); ImageProperties props = LoadImageProperties(); EXPECT_EQ("x86-generic", props.board); - EXPECT_EQ("dev-channel", props.current_channel); + EXPECT_EQ(kDevChannel, props.current_channel); EXPECT_EQ("https://www.google.com", props.omaha_url); MutableImageProperties mutable_props = LoadMutableImageProperties(); - EXPECT_EQ("beta-channel", mutable_props.target_channel); + EXPECT_EQ(kBetaChannel, mutable_props.target_channel); } TEST_F(ImagePropertiesTest, OverrideLockDownTest) { @@ -125,10 +125,10 @@ TEST_F(ImagePropertiesTest, OverrideLockDownTest) { SetLockDown(true); ImageProperties props = LoadImageProperties(); EXPECT_EQ("arm-generic", props.board); - EXPECT_EQ("dev-channel", props.current_channel); + EXPECT_EQ(kDevChannel, props.current_channel); EXPECT_EQ("https://www.google.com", props.omaha_url); MutableImageProperties mutable_props = LoadMutableImageProperties(); - EXPECT_EQ("stable-channel", mutable_props.target_channel); + EXPECT_EQ(kStableChannel, mutable_props.target_channel); } TEST_F(ImagePropertiesTest, BoardAppIdUsedForNonCanaryChannelTest) { @@ -139,7 +139,7 @@ TEST_F(ImagePropertiesTest, BoardAppIdUsedForNonCanaryChannelTest) { "CHROMEOS_CANARY_APPID=c\n" "CHROMEOS_RELEASE_TRACK=stable-channel\n")); ImageProperties props = LoadImageProperties(); - EXPECT_EQ("stable-channel", props.current_channel); + EXPECT_EQ(kStableChannel, props.current_channel); EXPECT_EQ("b", props.product_id); } @@ -151,7 +151,7 @@ TEST_F(ImagePropertiesTest, CanaryAppIdUsedForCanaryChannelTest) { "CHROMEOS_CANARY_APPID=c\n" "CHROMEOS_RELEASE_TRACK=canary-channel\n")); ImageProperties props = LoadImageProperties(); - EXPECT_EQ("canary-channel", props.current_channel); + EXPECT_EQ(kCanaryChannel, props.current_channel); EXPECT_EQ("c", props.canary_product_id); } @@ -162,7 +162,7 @@ TEST_F(ImagePropertiesTest, ReleaseAppIdUsedAsDefaultTest) { "CHROMEOS_CANARY_APPID=c\n" "CHROMEOS_RELEASE_TRACK=stable-channel\n")); ImageProperties props = LoadImageProperties(); - EXPECT_EQ("stable-channel", props.current_channel); + EXPECT_EQ(kStableChannel, props.current_channel); EXPECT_EQ("r", props.product_id); } diff --git a/cros/omaha_request_action_unittest.cc b/cros/omaha_request_action_unittest.cc index b325233d..c57066b1 100644 --- a/cros/omaha_request_action_unittest.cc +++ b/cros/omaha_request_action_unittest.cc @@ -2436,9 +2436,8 @@ TEST_F(OmahaRequestActionTest, TestChangingToMoreStableChannel) { request_params_.set_app_id("{22222222-2222-2222-2222-222222222222}"); request_params_.set_app_version("1.2.3.4"); request_params_.set_product_components("o.bundle=1"); - request_params_.set_current_channel("canary-channel"); - EXPECT_TRUE( - request_params_.SetTargetChannel("stable-channel", true, nullptr)); + request_params_.set_current_channel(kCanaryChannel); + EXPECT_TRUE(request_params_.SetTargetChannel(kStableChannel, true, nullptr)); request_params_.UpdateDownloadChannel(); EXPECT_TRUE(request_params_.ShouldPowerwash()); @@ -2466,9 +2465,8 @@ TEST_F(OmahaRequestActionTest, TestChangingToLessStableChannel) { request_params_.set_app_id("{11111111-1111-1111-1111-111111111111}"); request_params_.set_app_version("5.6.7.8"); request_params_.set_product_components("o.bundle=1"); - request_params_.set_current_channel("stable-channel"); - EXPECT_TRUE( - request_params_.SetTargetChannel("canary-channel", false, nullptr)); + request_params_.set_current_channel(kStableChannel); + EXPECT_TRUE(request_params_.SetTargetChannel(kCanaryChannel, false, nullptr)); request_params_.UpdateDownloadChannel(); EXPECT_FALSE(request_params_.ShouldPowerwash()); diff --git a/cros/omaha_request_params.cc b/cros/omaha_request_params.cc index c829a934..4bf16f32 100644 --- a/cros/omaha_request_params.cc +++ b/cros/omaha_request_params.cc @@ -50,12 +50,12 @@ namespace chromeos_update_engine { namespace { const char* kChannelsByStability[] = { // This list has to be sorted from least stable to most stable channel. - "canary-channel", - "dev-channel", - "beta-channel", - "stable-channel", - "ltc-channel", - "lts-channel", + kCanaryChannel, + kDevChannel, + kBetaChannel, + kStableChannel, + kLtcChannel, + kLtsChannel, }; } // namespace @@ -77,7 +77,7 @@ bool OmahaRequestParams::Init(const string& app_version, // Validation check the channel names. if (!IsValidChannel(image_props_.current_channel)) - image_props_.current_channel = "stable-channel"; + image_props_.current_channel = kStableChannel; if (!IsValidChannel(mutable_image_props_.target_channel)) mutable_image_props_.target_channel = image_props_.current_channel; @@ -86,7 +86,7 @@ bool OmahaRequestParams::Init(const string& app_version, if (IsCommercialChannel(mutable_image_props_.target_channel)) { LOG(WARNING) << "Commercial channel " << mutable_image_props_.target_channel << " can only be set by policy. Defaulting to stable-channel"; - mutable_image_props_.target_channel = "stable-channel"; + mutable_image_props_.target_channel = kStableChannel; } UpdateDownloadChannel(); @@ -271,7 +271,7 @@ bool OmahaRequestParams::IsValidChannel(const string& channel, // static bool OmahaRequestParams::IsCommercialChannel(const string& channel) { - return channel == "ltc-channel" || channel == "lts-channel"; + return channel == kLtcChannel || channel == kLtsChannel; } void OmahaRequestParams::set_root(const string& root) { @@ -306,8 +306,8 @@ bool OmahaRequestParams::ShouldPowerwash() const { } string OmahaRequestParams::GetAppId() const { - return download_channel_ == "canary-channel" ? image_props_.canary_product_id - : image_props_.product_id; + return download_channel_ == kCanaryChannel ? image_props_.canary_product_id + : image_props_.product_id; } string OmahaRequestParams::GetDlcAppId(const std::string& dlc_id) const { diff --git a/cros/omaha_request_params_unittest.cc b/cros/omaha_request_params_unittest.cc index 51373df5..be318fd8 100644 --- a/cros/omaha_request_params_unittest.cc +++ b/cros/omaha_request_params_unittest.cc @@ -73,7 +73,7 @@ string GetMachineType() { TEST_F(OmahaRequestParamsTest, MissingChannelTest) { EXPECT_TRUE(params_.Init("", "", {})); // By default, if no channel is set, we should track the stable-channel. - EXPECT_EQ("stable-channel", params_.target_channel()); + EXPECT_EQ(kStableChannel, params_.target_channel()); } TEST_F(OmahaRequestParamsTest, ForceVersionTest) { @@ -109,12 +109,12 @@ TEST_F(OmahaRequestParamsTest, SetTargetChannelTest) { OmahaRequestParams params; params.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params.Init("", "", {})); - EXPECT_TRUE(params.SetTargetChannel("canary-channel", false, nullptr)); + EXPECT_TRUE(params.SetTargetChannel(kCanaryChannel, false, nullptr)); EXPECT_FALSE(params.mutable_image_props_.is_powerwash_allowed); } params_.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params_.Init("", "", {})); - EXPECT_EQ("canary-channel", params_.target_channel()); + EXPECT_EQ(kCanaryChannel, params_.target_channel()); EXPECT_FALSE(params_.mutable_image_props_.is_powerwash_allowed); } @@ -123,11 +123,11 @@ TEST_F(OmahaRequestParamsTest, SetTargetCommercialChannelTest) { OmahaRequestParams params; params.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params.Init("", "", {})); - EXPECT_TRUE(params.SetTargetChannel("ltc-channel", false, nullptr)); + EXPECT_TRUE(params.SetTargetChannel(kLtcChannel, false, nullptr)); } params_.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params_.Init("", "", {})); - EXPECT_EQ("stable-channel", params_.target_channel()); + EXPECT_EQ(kStableChannel, params_.target_channel()); } TEST_F(OmahaRequestParamsTest, SetCommercialChannelUsingParamTest) { @@ -135,11 +135,11 @@ TEST_F(OmahaRequestParamsTest, SetCommercialChannelUsingParamTest) { OmahaRequestParams params; params.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params.Init("", "", {})); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", false, nullptr)); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, false, nullptr)); } params_.set_root(tempdir_.GetPath().value()); - EXPECT_TRUE(params_.Init("", "", {.target_channel = "ltc-channel"})); - EXPECT_EQ("ltc-channel", params_.target_channel()); + EXPECT_TRUE(params_.Init("", "", {.target_channel = kLtcChannel})); + EXPECT_EQ(kLtcChannel, params_.target_channel()); } TEST_F(OmahaRequestParamsTest, SetIsPowerwashAllowedTest) { @@ -147,12 +147,12 @@ TEST_F(OmahaRequestParamsTest, SetIsPowerwashAllowedTest) { OmahaRequestParams params; params.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params.Init("", "", {})); - EXPECT_TRUE(params.SetTargetChannel("canary-channel", true, nullptr)); + EXPECT_TRUE(params.SetTargetChannel(kCanaryChannel, true, nullptr)); EXPECT_TRUE(params.mutable_image_props_.is_powerwash_allowed); } params_.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params_.Init("", "", {})); - EXPECT_EQ("canary-channel", params_.target_channel()); + EXPECT_EQ(kCanaryChannel, params_.target_channel()); EXPECT_TRUE(params_.mutable_image_props_.is_powerwash_allowed); } @@ -167,22 +167,22 @@ TEST_F(OmahaRequestParamsTest, SetTargetChannelInvalidTest) { EXPECT_FALSE( params.SetTargetChannel("dogfood-channel", true, &error_message)); // The error message should include a message about the valid channels. - EXPECT_NE(string::npos, error_message.find("stable-channel")); + EXPECT_NE(string::npos, error_message.find(kStableChannel)); EXPECT_FALSE(params.mutable_image_props_.is_powerwash_allowed); } params_.set_root(tempdir_.GetPath().value()); EXPECT_TRUE(params_.Init("", "", {})); - EXPECT_EQ("stable-channel", params_.target_channel()); + EXPECT_EQ(kStableChannel, params_.target_channel()); EXPECT_FALSE(params_.mutable_image_props_.is_powerwash_allowed); } TEST_F(OmahaRequestParamsTest, IsValidChannelTest) { - EXPECT_TRUE(params_.IsValidChannel("canary-channel")); - EXPECT_TRUE(params_.IsValidChannel("stable-channel")); - EXPECT_TRUE(params_.IsValidChannel("beta-channel")); - EXPECT_TRUE(params_.IsValidChannel("dev-channel")); - EXPECT_TRUE(params_.IsValidChannel("ltc-channel")); - EXPECT_TRUE(params_.IsValidChannel("lts-channel")); + EXPECT_TRUE(params_.IsValidChannel(kCanaryChannel)); + EXPECT_TRUE(params_.IsValidChannel(kStableChannel)); + EXPECT_TRUE(params_.IsValidChannel(kBetaChannel)); + EXPECT_TRUE(params_.IsValidChannel(kDevChannel)); + EXPECT_TRUE(params_.IsValidChannel(kLtcChannel)); + EXPECT_TRUE(params_.IsValidChannel(kLtsChannel)); EXPECT_FALSE(params_.IsValidChannel("testimage-channel")); EXPECT_FALSE(params_.IsValidChannel("dogfood-channel")); EXPECT_FALSE(params_.IsValidChannel("some-channel")); @@ -195,51 +195,51 @@ TEST_F(OmahaRequestParamsTest, IsValidChannelTest) { } TEST_F(OmahaRequestParamsTest, SetTargetChannelWorks) { - params_.set_target_channel("dev-channel"); - EXPECT_EQ("dev-channel", params_.target_channel()); + params_.set_target_channel(kDevChannel); + EXPECT_EQ(kDevChannel, params_.target_channel()); // When an invalid value is set, it should be ignored. EXPECT_FALSE(params_.SetTargetChannel("invalid-channel", false, nullptr)); - EXPECT_EQ("dev-channel", params_.target_channel()); + EXPECT_EQ(kDevChannel, params_.target_channel()); // When set to a valid value, it should take effect. - EXPECT_TRUE(params_.SetTargetChannel("beta-channel", true, nullptr)); - EXPECT_EQ("beta-channel", params_.target_channel()); + EXPECT_TRUE(params_.SetTargetChannel(kBetaChannel, true, nullptr)); + EXPECT_EQ(kBetaChannel, params_.target_channel()); // When set to the same value, it should be idempotent. - EXPECT_TRUE(params_.SetTargetChannel("beta-channel", true, nullptr)); - EXPECT_EQ("beta-channel", params_.target_channel()); + EXPECT_TRUE(params_.SetTargetChannel(kBetaChannel, true, nullptr)); + EXPECT_EQ(kBetaChannel, params_.target_channel()); // When set to a valid value while a change is already pending, it should // succeed. - EXPECT_TRUE(params_.SetTargetChannel("stable-channel", true, nullptr)); - EXPECT_EQ("stable-channel", params_.target_channel()); + EXPECT_TRUE(params_.SetTargetChannel(kStableChannel, true, nullptr)); + EXPECT_EQ(kStableChannel, params_.target_channel()); // Set a different channel in mutable_image_props_. - params_.set_target_channel("stable-channel"); + params_.set_target_channel(kStableChannel); // When set to a valid value while a change is already pending, it should // succeed. params_.Init("", "", {}); - EXPECT_TRUE(params_.SetTargetChannel("beta-channel", true, nullptr)); + EXPECT_TRUE(params_.SetTargetChannel(kBetaChannel, true, nullptr)); // The target channel should reflect the change, but the download channel // should continue to retain the old value ... - EXPECT_EQ("beta-channel", params_.target_channel()); - EXPECT_EQ("stable-channel", params_.download_channel()); + EXPECT_EQ(kBetaChannel, params_.target_channel()); + EXPECT_EQ(kStableChannel, params_.download_channel()); // ... until we update the download channel explicitly. params_.UpdateDownloadChannel(); - EXPECT_EQ("beta-channel", params_.download_channel()); - EXPECT_EQ("beta-channel", params_.target_channel()); + EXPECT_EQ(kBetaChannel, params_.download_channel()); + EXPECT_EQ(kBetaChannel, params_.target_channel()); } TEST_F(OmahaRequestParamsTest, ChannelIndexTest) { - int canary = params_.GetChannelIndex("canary-channel"); - int dev = params_.GetChannelIndex("dev-channel"); - int beta = params_.GetChannelIndex("beta-channel"); - int stable = params_.GetChannelIndex("stable-channel"); - int ltc = params_.GetChannelIndex("ltc-channel"); - int lts = params_.GetChannelIndex("lts-channel"); + int canary = params_.GetChannelIndex(kCanaryChannel); + int dev = params_.GetChannelIndex(kDevChannel); + int beta = params_.GetChannelIndex(kBetaChannel); + int stable = params_.GetChannelIndex(kStableChannel); + int ltc = params_.GetChannelIndex(kLtcChannel); + int lts = params_.GetChannelIndex(kLtsChannel); EXPECT_LE(canary, dev); EXPECT_LE(dev, beta); EXPECT_LE(beta, stable); @@ -254,12 +254,12 @@ TEST_F(OmahaRequestParamsTest, ChannelIndexTest) { } TEST_F(OmahaRequestParamsTest, ToMoreStableChannelFlagTest) { - params_.image_props_.current_channel = "canary-channel"; - params_.download_channel_ = "stable-channel"; + params_.image_props_.current_channel = kCanaryChannel; + params_.download_channel_ = kStableChannel; EXPECT_TRUE(params_.ToMoreStableChannel()); - params_.image_props_.current_channel = "stable-channel"; + params_.image_props_.current_channel = kStableChannel; EXPECT_FALSE(params_.ToMoreStableChannel()); - params_.download_channel_ = "beta-channel"; + params_.download_channel_ = kBetaChannel; EXPECT_FALSE(params_.ToMoreStableChannel()); } @@ -272,8 +272,8 @@ TEST_F(OmahaRequestParamsTest, ShouldPowerwashTest) { params_.download_channel_ = "bar-channel"; EXPECT_TRUE(params_.ShouldPowerwash()); params_.image_props_.allow_arbitrary_channels = false; - params_.image_props_.current_channel = "canary-channel"; - params_.download_channel_ = "stable-channel"; + params_.image_props_.current_channel = kCanaryChannel; + params_.download_channel_ = kStableChannel; EXPECT_TRUE(params_.ShouldPowerwash()); } @@ -328,9 +328,9 @@ TEST_F(OmahaRequestParamsTest, MiniOsParams) { } TEST_F(OmahaRequestParamsTest, IsCommercialChannel) { - EXPECT_TRUE(OmahaRequestParams::IsCommercialChannel("lts-channel")); - EXPECT_TRUE(OmahaRequestParams::IsCommercialChannel("ltc-channel")); - EXPECT_FALSE(OmahaRequestParams::IsCommercialChannel("stable-channel")); + EXPECT_TRUE(OmahaRequestParams::IsCommercialChannel(kLtsChannel)); + EXPECT_TRUE(OmahaRequestParams::IsCommercialChannel(kLtcChannel)); + EXPECT_FALSE(OmahaRequestParams::IsCommercialChannel(kStableChannel)); EXPECT_FALSE(OmahaRequestParams::IsCommercialChannel("foo-channel")); } diff --git a/cros/omaha_response_handler_action_unittest.cc b/cros/omaha_response_handler_action_unittest.cc index 342bee41..d3de2a2a 100644 --- a/cros/omaha_response_handler_action_unittest.cc +++ b/cros/omaha_response_handler_action_unittest.cc @@ -510,8 +510,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(false); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("canary-channel"); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", true, nullptr)); + params.set_current_channel(kCanaryChannel); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, true, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("2.0.0.0"); @@ -538,8 +538,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(false); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("canary-channel"); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", false, nullptr)); + params.set_current_channel(kCanaryChannel); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, false, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("2.0.0.0"); @@ -566,8 +566,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(false); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("beta-channel"); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", true, nullptr)); + params.set_current_channel(kBetaChannel); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, true, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("12345.48.0.0"); @@ -594,8 +594,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(false); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("beta-channel"); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", true, nullptr)); + params.set_current_channel(kBetaChannel); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, true, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("12345.0.0.0"); @@ -625,8 +625,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(true); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("beta-channel"); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", true, nullptr)); + params.set_current_channel(kBetaChannel); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, true, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("12347.48.0.0"); @@ -659,8 +659,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(true); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("beta-channel"); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", true, nullptr)); + params.set_current_channel(kBetaChannel); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, true, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("12347.48.0.0"); @@ -692,8 +692,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(true); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("beta-channel"); - EXPECT_TRUE(params.SetTargetChannel("stable-channel", false, nullptr)); + params.set_current_channel(kBetaChannel); + EXPECT_TRUE(params.SetTargetChannel(kStableChannel, false, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("12347.48.0.0"); @@ -720,8 +720,8 @@ TEST_F(OmahaResponseHandlerActionTest, OmahaRequestParams params; FakeSystemState::Get()->fake_hardware()->SetIsOfficialBuild(false); params.set_root(tempdir.GetPath().value()); - params.set_current_channel("stable-channel"); - EXPECT_TRUE(params.SetTargetChannel("canary-channel", false, nullptr)); + params.set_current_channel(kStableChannel); + EXPECT_TRUE(params.SetTargetChannel(kCanaryChannel, false, nullptr)); params.UpdateDownloadChannel(); params.set_app_version("1.0.0.0"); diff --git a/cros/update_attempter_unittest.cc b/cros/update_attempter_unittest.cc index 7c4d3cb6..b1c74d0e 100644 --- a/cros/update_attempter_unittest.cc +++ b/cros/update_attempter_unittest.cc @@ -1720,7 +1720,7 @@ TEST_F(UpdateAttempterTest, ChannelDowngradeNoRollback) { ASSERT_TRUE(tempdir.CreateUniqueTempDir()); FakeSystemState::Get()->request_params()->set_root(tempdir.GetPath().value()); attempter_.CalculateUpdateParams({ - .target_channel = "stable-channel", + .target_channel = kStableChannel, }); EXPECT_FALSE( FakeSystemState::Get()->request_params()->is_powerwash_allowed()); @@ -1732,7 +1732,7 @@ TEST_F(UpdateAttempterTest, ChannelDowngradeRollback) { FakeSystemState::Get()->request_params()->set_root(tempdir.GetPath().value()); attempter_.CalculateUpdateParams({ .rollback_on_channel_downgrade = true, - .target_channel = "stable-channel", + .target_channel = kStableChannel, }); EXPECT_TRUE(FakeSystemState::Get()->request_params()->is_powerwash_allowed()); } diff --git a/update_manager/enterprise_device_policy_impl_unittest.cc b/update_manager/enterprise_device_policy_impl_unittest.cc index 30f04d28..11b1da91 100644 --- a/update_manager/enterprise_device_policy_impl_unittest.cc +++ b/update_manager/enterprise_device_policy_impl_unittest.cc @@ -24,6 +24,7 @@ #include "update_engine/update_manager/update_check_allowed_policy_data.h" using chromeos_update_engine::FakeSystemState; +using chromeos_update_engine::kStableChannel; using std::string; namespace chromeos_update_manager { @@ -157,7 +158,7 @@ TEST_F(UmEnterpriseDevicePolicyImplTest, ChannelDowngradeBehaviorNoRollback) { fake_state_.device_policy_provider()->var_release_channel_delegated()->reset( new bool(false)); fake_state_.device_policy_provider()->var_release_channel()->reset( - new std::string("stable-channel")); + new std::string(kStableChannel)); EXPECT_EQ(EvalStatus::kContinue, evaluator_->Evaluate()); EXPECT_FALSE(uca_data_->update_check_params.rollback_on_channel_downgrade); @@ -167,7 +168,7 @@ TEST_F(UmEnterpriseDevicePolicyImplTest, ChannelDowngradeBehaviorRollback) { fake_state_.device_policy_provider()->var_release_channel_delegated()->reset( new bool(false)); fake_state_.device_policy_provider()->var_release_channel()->reset( - new std::string("stable-channel")); + new std::string(kStableChannel)); fake_state_.device_policy_provider()->var_channel_downgrade_behavior()->reset( new ChannelDowngradeBehavior(ChannelDowngradeBehavior::kRollback)); |