Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: components/update_client/utils_unittest.cc

Issue 2498873003: Refactor how the updater state data is serialized in update checks. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/update_client/utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/update_client/utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698