update_engine: Don't keep pointer to SystemState available objects
These objects are available thorugh SystemState. No need to keep pointer
to them in various classes (OmahaRequestBuilderXml in this case). This
makes testing/debugging easier because there will be one central
location for getting pointers to these values.
BUG=b:171829801
TEST=cros_workon_make --board reef --test update_engine
Change-Id: I02a36afdc7dcb00e02b1a61263141745afc7fb26
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2543814
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/common/dynamic_partition_control_interface.h b/common/dynamic_partition_control_interface.h
index 7c2d0b0..f47958d 100644
--- a/common/dynamic_partition_control_interface.h
+++ b/common/dynamic_partition_control_interface.h
@@ -26,6 +26,7 @@
#include "update_engine/common/action.h"
#include "update_engine/common/cleanup_previous_update_action_delegate.h"
#include "update_engine/common/error_code.h"
+#include "update_engine/common/prefs_interface.h"
#include "update_engine/update_metadata.pb.h"
namespace chromeos_update_engine {
@@ -42,7 +43,6 @@
};
class BootControlInterface;
-class PrefsInterface;
class DynamicPartitionControlInterface {
public:
diff --git a/cros/omaha_request_action.cc b/cros/omaha_request_action.cc
index 6f270c0..f847194 100644
--- a/cros/omaha_request_action.cc
+++ b/cros/omaha_request_action.cc
@@ -456,19 +456,17 @@
return;
}
- auto* params = SystemState::Get()->request_params();
OmahaRequestBuilderXml omaha_request(event_.get(),
- params,
ping_only_,
ShouldPing(), // include_ping
ping_active_days_,
ping_roll_call_days_,
GetInstallDate(),
- SystemState::Get()->prefs(),
session_id_);
string request_post = omaha_request.GetRequest();
// Set X-Goog-Update headers.
+ const auto* params = SystemState::Get()->request_params();
http_fetcher_->SetHeader(kXGoogleUpdateInteractivity,
params->interactive() ? "fg" : "bg");
http_fetcher_->SetHeader(kXGoogleUpdateAppId, params->GetAppId());
diff --git a/cros/omaha_request_builder_xml.cc b/cros/omaha_request_builder_xml.cc
index 739abbf..6cd9ab8 100644
--- a/cros/omaha_request_builder_xml.cc
+++ b/cros/omaha_request_builder_xml.cc
@@ -28,7 +28,7 @@
#include <base/time/time.h>
#include "update_engine/common/constants.h"
-#include "update_engine/common/prefs_interface.h"
+#include "update_engine/common/system_state.h"
#include "update_engine/common/utils.h"
#include "update_engine/cros/omaha_request_params.h"
@@ -144,20 +144,21 @@
}
if (!ping_only_) {
if (!app_data.skip_update) {
+ const auto* params = SystemState::Get()->request_params();
app_body += " <updatecheck";
- if (!params_->target_version_prefix().empty()) {
+ if (!params->target_version_prefix().empty()) {
app_body += base::StringPrintf(
" targetversionprefix=\"%s\"",
- XmlEncodeWithDefault(params_->target_version_prefix()).c_str());
+ XmlEncodeWithDefault(params->target_version_prefix()).c_str());
// Rollback requires target_version_prefix set.
- if (params_->rollback_allowed()) {
+ if (params->rollback_allowed()) {
app_body += " rollback_allowed=\"true\"";
}
}
- if (!params_->lts_tag().empty()) {
+ if (!params->lts_tag().empty()) {
app_body += base::StringPrintf(
" ltstag=\"%s\"",
- XmlEncodeWithDefault(params_->lts_tag()).c_str());
+ XmlEncodeWithDefault(params->lts_tag()).c_str());
}
app_body += "></updatecheck>\n";
}
@@ -170,8 +171,9 @@
// for ping-only requests because they come before the client has
// rebooted. The previous version event is also not sent if it was already
// sent for this new version with a previous updatecheck.
+ auto* prefs = SystemState::Get()->prefs();
string prev_version;
- if (!prefs_->GetString(kPrefsPreviousVersion, &prev_version)) {
+ if (!prefs->GetString(kPrefsPreviousVersion, &prev_version)) {
prev_version = kNoVersion;
}
// We only store a non-empty previous version value after a successful
@@ -184,7 +186,7 @@
OmahaEvent::kTypeRebootedAfterUpdate,
OmahaEvent::kResultSuccess,
XmlEncodeWithDefault(prev_version, kNoVersion).c_str());
- LOG_IF(WARNING, !prefs_->SetString(kPrefsPreviousVersion, ""))
+ LOG_IF(WARNING, !prefs->SetString(kPrefsPreviousVersion, ""))
<< "Unable to reset the previous version.";
}
}
@@ -226,9 +228,10 @@
} else {
// There's nothing wrong with not having a given cohort setting, so we check
// existence first to avoid the warning log message.
- if (!prefs_->Exists(prefs_key))
+ const auto* prefs = SystemState::Get()->prefs();
+ if (!prefs->Exists(prefs_key))
return "";
- if (!prefs_->GetString(prefs_key, &cohort_value) || cohort_value.empty())
+ if (!prefs->GetString(prefs_key, &cohort_value) || cohort_value.empty())
return "";
}
// This is a validity check to avoid sending a huge XML file back to Ohama due
@@ -263,11 +266,12 @@
string OmahaRequestBuilderXml::GetApp(const OmahaAppData& app_data) const {
string app_body = GetAppBody(app_data);
string app_versions;
+ const auto* params = SystemState::Get()->request_params();
// If we are downgrading to a more stable channel and we are allowed to do
// powerwash, then pass 0.0.0.0 as the version. This is needed to get the
// highest-versioned payload on the destination channel.
- if (params_->ShouldPowerwash()) {
+ if (params->ShouldPowerwash()) {
LOG(INFO) << "Passing OS version as 0.0.0.0 as we are set to powerwash "
<< "on downgrading to the version in the more stable channel";
app_versions = "version=\"" + string(kNoVersion) + "\" from_version=\"" +
@@ -277,16 +281,16 @@
XmlEncodeWithDefault(app_data.version, kNoVersion) + "\" ";
}
- string download_channel = params_->download_channel();
+ string download_channel = params->download_channel();
string app_channels =
"track=\"" + XmlEncodeWithDefault(download_channel) + "\" ";
- if (params_->current_channel() != download_channel) {
+ if (params->current_channel() != download_channel) {
app_channels += "from_track=\"" +
- XmlEncodeWithDefault(params_->current_channel()) + "\" ";
+ XmlEncodeWithDefault(params->current_channel()) + "\" ";
}
string delta_okay_str =
- params_->delta_okay() && !params_->is_install() ? "true" : "false";
+ params->delta_okay() && !params->is_install() ? "true" : "false";
// If install_date_days is not set (e.g. its value is -1 ), don't
// include the attribute.
@@ -302,16 +306,17 @@
string cohorthint_key = kPrefsOmahaCohortHint;
// Override the cohort keys for DLC App IDs.
- const auto& dlc_apps_params = params_->dlc_apps_params();
+ const auto& dlc_apps_params = params->dlc_apps_params();
auto itr = dlc_apps_params.find(app_data.id);
if (itr != dlc_apps_params.end()) {
auto dlc_id = itr->second.name;
+ const auto* prefs = SystemState::Get()->prefs();
cohort_key =
- prefs_->CreateSubKey({kDlcPrefsSubDir, dlc_id, kPrefsOmahaCohort});
+ prefs->CreateSubKey({kDlcPrefsSubDir, dlc_id, kPrefsOmahaCohort});
cohortname_key =
- prefs_->CreateSubKey({kDlcPrefsSubDir, dlc_id, kPrefsOmahaCohortName});
+ prefs->CreateSubKey({kDlcPrefsSubDir, dlc_id, kPrefsOmahaCohortName});
cohorthint_key =
- prefs_->CreateSubKey({kDlcPrefsSubDir, dlc_id, kPrefsOmahaCohortHint});
+ prefs->CreateSubKey({kDlcPrefsSubDir, dlc_id, kPrefsOmahaCohortHint});
}
app_cohort_args += GetCohortArg("cohort", cohort_key);
@@ -320,23 +325,23 @@
app_cohort_args +=
GetCohortArg("cohorthint",
cohorthint_key,
- params_->autoupdate_token() /* override_value */);
+ params->autoupdate_token() /* override_value */);
string fingerprint_arg;
- if (!params_->os_build_fingerprint().empty()) {
+ if (!params->os_build_fingerprint().empty()) {
fingerprint_arg = "fingerprint=\"" +
- XmlEncodeWithDefault(params_->os_build_fingerprint()) +
+ XmlEncodeWithDefault(params->os_build_fingerprint()) +
"\" ";
}
string buildtype_arg;
- if (!params_->os_build_type().empty()) {
+ if (!params->os_build_type().empty()) {
buildtype_arg = "os_build_type=\"" +
- XmlEncodeWithDefault(params_->os_build_type()) + "\" ";
+ XmlEncodeWithDefault(params->os_build_type()) + "\" ";
}
string product_components_args;
- if (!params_->ShouldPowerwash() && !app_data.product_components.empty()) {
+ if (!params->ShouldPowerwash() && !app_data.product_components.empty()) {
brillo::KeyValueStore store;
if (store.LoadFromString(app_data.product_components)) {
for (const string& key : store.GetKeys()) {
@@ -362,9 +367,9 @@
}
string requisition_arg;
- if (!params_->device_requisition().empty()) {
+ if (!params->device_requisition().empty()) {
requisition_arg = "requisition=\"" +
- XmlEncodeWithDefault(params_->device_requisition()) +
+ XmlEncodeWithDefault(params->device_requisition()) +
"\" ";
}
@@ -377,14 +382,14 @@
product_components_args +
fingerprint_arg +
buildtype_arg +
- "board=\"" + XmlEncodeWithDefault(params_->os_board()) + "\" " +
- "hardware_class=\"" + XmlEncodeWithDefault(params_->hwid()) + "\" " +
+ "board=\"" + XmlEncodeWithDefault(params->os_board()) + "\" " +
+ "hardware_class=\"" + XmlEncodeWithDefault(params->hwid()) + "\" " +
"delta_okay=\"" + delta_okay_str + "\" " +
install_date_in_days_str +
// DLC excluded for installs and updates.
(app_data.is_dlc ? "" :
- "lang=\"" + XmlEncodeWithDefault(params_->app_lang(), "en-US") + "\" " +
+ "lang=\"" + XmlEncodeWithDefault(params->app_lang(), "en-US") + "\" " +
requisition_arg) +
">\n" +
@@ -395,18 +400,20 @@
}
string OmahaRequestBuilderXml::GetOs() const {
+ const auto* params = SystemState::Get()->request_params();
string os_xml =
" <os "
"version=\"" +
- XmlEncodeWithDefault(params_->os_version()) + "\" " + "platform=\"" +
- XmlEncodeWithDefault(params_->os_platform()) + "\" " + "sp=\"" +
- XmlEncodeWithDefault(params_->os_sp()) +
+ XmlEncodeWithDefault(params->os_version()) + "\" " + "platform=\"" +
+ XmlEncodeWithDefault(params->os_platform()) + "\" " + "sp=\"" +
+ XmlEncodeWithDefault(params->os_sp()) +
"\">"
"</os>\n";
return os_xml;
}
string OmahaRequestBuilderXml::GetRequest() const {
+ const auto* params = SystemState::Get()->request_params();
string os_xml = GetOs();
string app_xml = GetApps();
@@ -419,7 +426,7 @@
session_id_.c_str(),
constants::kOmahaUpdaterID,
kOmahaUpdaterVersion,
- params_->interactive() ? "ondemandupdate" : "scheduler",
+ params->interactive() ? "ondemandupdate" : "scheduler",
os_xml.c_str(),
app_xml.c_str());
@@ -427,22 +434,23 @@
}
string OmahaRequestBuilderXml::GetApps() const {
+ const auto* params = SystemState::Get()->request_params();
string app_xml = "";
OmahaAppData product_app = {
- .id = params_->GetAppId(),
- .version = params_->app_version(),
- .product_components = params_->product_components(),
+ .id = params->GetAppId(),
+ .version = params->app_version(),
+ .product_components = params->product_components(),
// Skips updatecheck for platform app in case of an install operation.
- .skip_update = params_->is_install(),
+ .skip_update = params->is_install(),
.is_dlc = false,
.app_params = {.active_counting_type = OmahaRequestParams::kDayBased,
.send_ping = include_ping_}};
app_xml += GetApp(product_app);
- for (const auto& it : params_->dlc_apps_params()) {
+ for (const auto& it : params->dlc_apps_params()) {
OmahaAppData dlc_app_data = {
.id = it.first,
- .version = params_->is_install() ? kNoVersion : params_->app_version(),
+ .version = params->is_install() ? kNoVersion : params->app_version(),
.skip_update = false,
.is_dlc = true,
.app_params = it.second};
diff --git a/cros/omaha_request_builder_xml.h b/cros/omaha_request_builder_xml.h
index 6bbc84e..7c246f7 100644
--- a/cros/omaha_request_builder_xml.h
+++ b/cros/omaha_request_builder_xml.h
@@ -121,22 +121,18 @@
class OmahaRequestBuilderXml : OmahaRequestBuilder {
public:
OmahaRequestBuilderXml(const OmahaEvent* event,
- OmahaRequestParams* params,
bool ping_only,
bool include_ping,
int ping_active_days,
int ping_roll_call_days,
int install_date_in_days,
- PrefsInterface* prefs,
const std::string& session_id)
: event_(event),
- params_(params),
ping_only_(ping_only),
include_ping_(include_ping),
ping_active_days_(ping_active_days),
ping_roll_call_days_(ping_roll_call_days),
install_date_in_days_(install_date_in_days),
- prefs_(prefs),
session_id_(session_id) {}
~OmahaRequestBuilderXml() override = default;
@@ -181,13 +177,11 @@
const OmahaRequestParams::AppParams& app_params) const;
const OmahaEvent* event_;
- OmahaRequestParams* params_;
bool ping_only_;
bool include_ping_;
int ping_active_days_;
int ping_roll_call_days_;
int install_date_in_days_;
- PrefsInterface* prefs_;
std::string session_id_;
DISALLOW_COPY_AND_ASSIGN(OmahaRequestBuilderXml);
diff --git a/cros/omaha_request_builder_xml_unittest.cc b/cros/omaha_request_builder_xml_unittest.cc
index 74d616d..1ef0278 100644
--- a/cros/omaha_request_builder_xml_unittest.cc
+++ b/cros/omaha_request_builder_xml_unittest.cc
@@ -61,10 +61,15 @@
class OmahaRequestBuilderXmlTest : public ::testing::Test {
protected:
- void SetUp() override { FakeSystemState::CreateInstance(); }
+ void SetUp() override {
+ FakeSystemState::CreateInstance();
+ FakeSystemState::Get()->set_request_params(¶ms_);
+ }
void TearDown() override {}
static constexpr size_t kGuidSize = 36;
+
+ OmahaRequestParams params_;
};
TEST_F(OmahaRequestBuilderXmlTest, XmlEncodeTest) {
@@ -93,16 +98,13 @@
}
TEST_F(OmahaRequestBuilderXmlTest, PlatformGetAppTest) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_device_requisition("device requisition");
+ params_.set_device_requisition("device requisition");
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
OmahaAppData dlc_app_data = {.id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
.version = "",
@@ -117,16 +119,13 @@
}
TEST_F(OmahaRequestBuilderXmlTest, DlcGetAppTest) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_device_requisition("device requisition");
+ params_.set_device_requisition("device requisition");
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
OmahaAppData dlc_app_data = {
.id = "_dlc_id", .version = "", .skip_update = false, .is_dlc = true};
@@ -139,15 +138,12 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlRequestIdTest) {
- OmahaRequestParams omaha_request_params;
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
const string key = "requestid";
@@ -160,15 +156,12 @@
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlSessionIdTest) {
const string gen_session_id = base::GenerateGUID();
- OmahaRequestParams omaha_request_params;
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
gen_session_id};
const string request_xml = omaha_request.GetRequest();
const string key = "sessionid";
@@ -182,15 +175,12 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlPlatformUpdateTest) {
- OmahaRequestParams omaha_request_params;
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(1, CountSubstringInString(request_xml, "<updatecheck"))
@@ -198,18 +188,15 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlPlatformUpdateWithDlcsTest) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_dlc_apps_params(
- {{omaha_request_params.GetDlcAppId("dlc_no_0"), {.name = "dlc_no_0"}},
- {omaha_request_params.GetDlcAppId("dlc_no_1"), {.name = "dlc_no_1"}}});
+ params_.set_dlc_apps_params(
+ {{params_.GetDlcAppId("dlc_no_0"), {.name = "dlc_no_0"}},
+ {params_.GetDlcAppId("dlc_no_1"), {.name = "dlc_no_1"}}});
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(3, CountSubstringInString(request_xml, "<updatecheck"))
@@ -217,20 +204,17 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlDlcInstallationTest) {
- OmahaRequestParams omaha_request_params;
const std::map<std::string, OmahaRequestParams::AppParams> dlcs = {
- {omaha_request_params.GetDlcAppId("dlc_no_0"), {.name = "dlc_no_0"}},
- {omaha_request_params.GetDlcAppId("dlc_no_1"), {.name = "dlc_no_1"}}};
- omaha_request_params.set_dlc_apps_params(dlcs);
- omaha_request_params.set_is_install(true);
+ {params_.GetDlcAppId("dlc_no_0"), {.name = "dlc_no_0"}},
+ {params_.GetDlcAppId("dlc_no_1"), {.name = "dlc_no_1"}}};
+ params_.set_dlc_apps_params(dlcs);
+ params_.set_is_install(true);
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(2, CountSubstringInString(request_xml, "<updatecheck"))
@@ -256,39 +240,33 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlDlcNoPing) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_dlc_apps_params(
- {{omaha_request_params.GetDlcAppId("dlc_no_0"), {.name = "dlc_no_0"}}});
+ params_.set_dlc_apps_params(
+ {{params_.GetDlcAppId("dlc_no_0"), {.name = "dlc_no_0"}}});
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(0, CountSubstringInString(request_xml, "<ping")) << request_xml;
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlDlcPingRollCallNoActive) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_dlc_apps_params(
- {{omaha_request_params.GetDlcAppId("dlc_no_0"),
+ params_.set_dlc_apps_params(
+ {{params_.GetDlcAppId("dlc_no_0"),
{.active_counting_type = OmahaRequestParams::kDateBased,
.name = "dlc_no_0",
.ping_date_last_active = 25,
.ping_date_last_rollcall = 36,
.send_ping = true}}});
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(1, CountSubstringInString(request_xml, "<ping rd=\"36\""))
@@ -296,9 +274,8 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlDlcPingRollCallAndActive) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_dlc_apps_params(
- {{omaha_request_params.GetDlcAppId("dlc_no_0"),
+ params_.set_dlc_apps_params(
+ {{params_.GetDlcAppId("dlc_no_0"),
{.active_counting_type = OmahaRequestParams::kDateBased,
.name = "dlc_no_0",
.ping_active = 1,
@@ -306,13 +283,11 @@
.ping_date_last_rollcall = 36,
.send_ping = true}}});
OmahaRequestBuilderXml omaha_request{nullptr,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(1,
@@ -322,16 +297,13 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlUpdateCompleteEvent) {
- OmahaRequestParams omaha_request_params;
OmahaEvent event(OmahaEvent::kTypeUpdateComplete);
OmahaRequestBuilderXml omaha_request{&event,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
LOG(INFO) << request_xml;
@@ -344,20 +316,17 @@
TEST_F(OmahaRequestBuilderXmlTest,
GetRequestXmlUpdateCompleteEventSomeDlcsExcluded) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_dlc_apps_params({
- {omaha_request_params.GetDlcAppId("dlc_1"), {.updated = true}},
- {omaha_request_params.GetDlcAppId("dlc_2"), {.updated = false}},
+ params_.set_dlc_apps_params({
+ {params_.GetDlcAppId("dlc_1"), {.updated = true}},
+ {params_.GetDlcAppId("dlc_2"), {.updated = false}},
});
OmahaEvent event(OmahaEvent::kTypeUpdateComplete);
OmahaRequestBuilderXml omaha_request{&event,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(
@@ -375,20 +344,17 @@
TEST_F(OmahaRequestBuilderXmlTest,
GetRequestXmlUpdateCompleteEventAllDlcsExcluded) {
- OmahaRequestParams omaha_request_params;
- omaha_request_params.set_dlc_apps_params({
- {omaha_request_params.GetDlcAppId("dlc_1"), {.updated = false}},
- {omaha_request_params.GetDlcAppId("dlc_2"), {.updated = false}},
+ params_.set_dlc_apps_params({
+ {params_.GetDlcAppId("dlc_1"), {.updated = false}},
+ {params_.GetDlcAppId("dlc_2"), {.updated = false}},
});
OmahaEvent event(OmahaEvent::kTypeUpdateComplete);
OmahaRequestBuilderXml omaha_request{&event,
- &omaha_request_params,
false,
false,
0,
0,
0,
- FakeSystemState::Get()->prefs(),
""};
const string request_xml = omaha_request.GetRequest();
EXPECT_EQ(
@@ -405,14 +371,12 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlDlcCohortMissingCheck) {
- OmahaRequestParams omaha_request_params;
constexpr char kDlcId[] = "test-dlc-id";
- omaha_request_params.set_dlc_apps_params(
- {{omaha_request_params.GetDlcAppId(kDlcId), {.name = kDlcId}}});
+ params_.set_dlc_apps_params(
+ {{params_.GetDlcAppId(kDlcId), {.name = kDlcId}}});
auto* mock_prefs = FakeSystemState::Get()->mock_prefs();
OmahaEvent event(OmahaEvent::kTypeUpdateDownloadStarted);
- OmahaRequestBuilderXml omaha_request{
- &event, &omaha_request_params, false, false, 0, 0, 0, mock_prefs, ""};
+ OmahaRequestBuilderXml omaha_request{&event, false, false, 0, 0, 0, ""};
// OS App ID Expectations.
EXPECT_CALL(*mock_prefs, Exists(kPrefsOmahaCohort));
EXPECT_CALL(*mock_prefs, Exists(kPrefsOmahaCohortName));
@@ -438,15 +402,13 @@
}
TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlDlcCohortCheck) {
- OmahaRequestParams omaha_request_params;
const string kDlcId = "test-dlc-id";
- omaha_request_params.set_dlc_apps_params(
- {{omaha_request_params.GetDlcAppId(kDlcId), {.name = kDlcId}}});
+ params_.set_dlc_apps_params(
+ {{params_.GetDlcAppId(kDlcId), {.name = kDlcId}}});
FakePrefs fake_prefs;
FakeSystemState::Get()->set_prefs(&fake_prefs);
OmahaEvent event(OmahaEvent::kTypeUpdateDownloadStarted);
- OmahaRequestBuilderXml omaha_request{
- &event, &omaha_request_params, false, false, 0, 0, 0, &fake_prefs, ""};
+ OmahaRequestBuilderXml omaha_request{&event, false, false, 0, 0, 0, ""};
// DLC App ID Expectations.
const string dlc_cohort_key = PrefsInterface::CreateSubKey(
{kDlcPrefsSubDir, kDlcId, kPrefsOmahaCohort});