| Index: components/update_client/utils_unittest.cc
|
| diff --git a/components/update_client/utils_unittest.cc b/components/update_client/utils_unittest.cc
|
| index 9370a879b0633cb4500e46735bfd5f251d0781da..8cadf1382ffce379062694a5cbf31c0738a0378b 100644
|
| --- a/components/update_client/utils_unittest.cc
|
| +++ b/components/update_client/utils_unittest.cc
|
| @@ -3,7 +3,9 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/files/file_path.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/path_service.h"
|
| +#include "components/update_client/updater_state.h"
|
| #include "components/update_client/utils.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "url/gurl.h"
|
| @@ -25,23 +27,25 @@ namespace update_client {
|
|
|
| TEST(UpdateClientUtils, BuildProtocolRequest_ProdIdVersion) {
|
| // Verifies that |prod_id| and |version| are serialized.
|
| - const string request =
|
| - BuildProtocolRequest("some_prod_id", "1.0", "", "", "", "", "", "");
|
| + const string request = BuildProtocolRequest("some_prod_id", "1.0", "", "", "",
|
| + "", "", "", nullptr);
|
| EXPECT_NE(string::npos, request.find(" version=\"some_prod_id-1.0\" "));
|
| }
|
|
|
| TEST(UpdateClientUtils, BuildProtocolRequest_DownloadPreference) {
|
| // Verifies that an empty |download_preference| is not serialized.
|
| const string request_no_dlpref =
|
| - BuildProtocolRequest("", "", "", "", "", "", "", "");
|
| + BuildProtocolRequest("", "", "", "", "", "", "", "", nullptr);
|
| EXPECT_EQ(string::npos, request_no_dlpref.find(" dlpref="));
|
|
|
| // Verifies that |download_preference| is serialized.
|
| const string request_with_dlpref =
|
| - BuildProtocolRequest("", "", "", "", "", "some pref", "", "");
|
| + BuildProtocolRequest("", "", "", "", "", "some pref", "", "", nullptr);
|
| EXPECT_NE(string::npos, request_with_dlpref.find(" dlpref=\"some pref\""));
|
| }
|
|
|
| +TEST(UpdateClientUtils, BuildProtocolRequest_UpdaterState) {}
|
| +
|
| TEST(UpdateClientUtils, VerifyFileHash256) {
|
| EXPECT_TRUE(VerifyFileHash256(
|
| MakeTestFilePath("jebgalgnebhfojomionfpkfelancnnkf.crx"),
|
| @@ -166,4 +170,35 @@ TEST(UpdateClientUtils, RemoveUnsecureUrls) {
|
| EXPECT_EQ(0u, urls.size());
|
| }
|
|
|
| +TEST(UpdateClientUtils, BuildProtocolRequestUpdaterStateAttributes) {
|
| + // When no updater state is provided, then check that the elements and
|
| + // attributes related to the updater state are not serialized.
|
| + std::string request =
|
| + BuildProtocolRequest("", "", "", "", "", "", "", "", nullptr).c_str();
|
| + EXPECT_EQ(std::string::npos, request.find(" domainjoined"));
|
| + EXPECT_EQ(std::string::npos, request.find("<updater"));
|
| +
|
| + UpdaterState::Attributes attributes;
|
| + attributes["domainjoined"] = "1";
|
| + attributes["name"] = "Omaha";
|
| + attributes["version"] = "1.2.3.4";
|
| + attributes["laststarted"] = "1";
|
| + attributes["lastchecked"] = "2";
|
| + attributes["autoupdatecheckenabled"] = "0";
|
| + attributes["updatepolicy"] = "-1";
|
| + request = BuildProtocolRequest(
|
| + "", "", "", "", "", "", "", "",
|
| + base::MakeUnique<UpdaterState::Attributes>(attributes));
|
| + EXPECT_NE(std::string::npos, request.find(" domainjoined=\"1\""));
|
| + const std::string updater_element =
|
| + "<updater autoupdatecheckenabled=\"0\" "
|
| + "lastchecked=\"2\" laststarted=\"1\" name=\"Omaha\" "
|
| + "updatepolicy=\"-1\" version=\"1.2.3.4\"/>";
|
| +#if defined(GOOGLE_CHROME_BUILD)
|
| + EXPECT_NE(std::string::npos, request.find(updater_element));
|
| +#else
|
| + EXPECT_EQ(std::string::npos, request.find(updater_element));
|
| +#endif // GOOGLE_CHROME_BUILD
|
| +}
|
| +
|
| } // namespace update_client
|
|
|