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

Side by Side Diff: components/update_client/update_checker_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 unified diff | Download patch
« no previous file with comments | « components/update_client/update_checker.cc ('k') | components/update_client/updater_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/update_client/update_checker.h" 5 #include "components/update_client/update_checker.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 base::Unretained(this))); 185 base::Unretained(this)));
186 186
187 RunThreads(); 187 RunThreads();
188 188
189 EXPECT_EQ(1, post_interceptor_->GetHitCount()) 189 EXPECT_EQ(1, post_interceptor_->GetHitCount())
190 << post_interceptor_->GetRequestsAsString(); 190 << post_interceptor_->GetRequestsAsString();
191 ASSERT_EQ(1, post_interceptor_->GetCount()) 191 ASSERT_EQ(1, post_interceptor_->GetCount())
192 << post_interceptor_->GetRequestsAsString(); 192 << post_interceptor_->GetRequestsAsString();
193 193
194 // Sanity check the request. 194 // Sanity check the request.
195 const auto request = post_interceptor_->GetRequests()[0];
195 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( 196 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find(
196 "request protocol=\"3.0\" extra=\"params\"")); 197 "request protocol=\"3.0\" extra=\"params\""));
197 // The request must not contain any "dlpref" in the default case. 198 // The request must not contain any "dlpref" in the default case.
198 EXPECT_EQ(string::npos, 199 EXPECT_EQ(string::npos, request.find(" dlpref=\""));
199 post_interceptor_->GetRequests()[0].find(" dlpref=\""));
200 EXPECT_NE( 200 EXPECT_NE(
201 string::npos, 201 string::npos,
202 post_interceptor_->GetRequests()[0].find( 202 request.find(
203 std::string("<app appid=\"") + kUpdateItemId + 203 std::string("<app appid=\"") + kUpdateItemId +
204 "\" version=\"0.9\" " 204 "\" version=\"0.9\" "
205 "brand=\"TEST\" ap=\"some_ap\"><updatecheck/><ping rd=\"-2\" ")); 205 "brand=\"TEST\" ap=\"some_ap\"><updatecheck/><ping rd=\"-2\" "));
206 EXPECT_NE(string::npos, 206 EXPECT_NE(string::npos,
207 post_interceptor_->GetRequests()[0].find( 207 request.find("<packages><package fp=\"fp1\"/></packages></app>"));
208 "<packages><package fp=\"fp1\"/></packages></app>"));
209 208
210 EXPECT_NE(string::npos, 209 EXPECT_NE(string::npos, request.find("<hw physmemory="));
211 post_interceptor_->GetRequests()[0].find("<hw physmemory="));
212 210
213 // Tests that the progid is injected correctly from the configurator. 211 // Tests that the progid is injected correctly from the configurator.
214 EXPECT_NE(string::npos, 212 EXPECT_NE(
215 post_interceptor_->GetRequests()[0].find( 213 string::npos,
216 " version=\"fake_prodid-30.0\" prodversion=\"30.0\" ")); 214 request.find(" version=\"fake_prodid-30.0\" prodversion=\"30.0\" "));
217 215
218 // Sanity check the arguments of the callback after parsing. 216 // Sanity check the arguments of the callback after parsing.
219 EXPECT_EQ(0, error_); 217 EXPECT_EQ(0, error_);
220 EXPECT_EQ(1ul, results_.list.size()); 218 EXPECT_EQ(1ul, results_.list.size());
221 EXPECT_STREQ(kUpdateItemId, results_.list[0].extension_id.c_str()); 219 EXPECT_STREQ(kUpdateItemId, results_.list[0].extension_id.c_str());
222 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str()); 220 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str());
221
222 #if (OS_WIN)
223 EXPECT_NE(string::npos, request.find(" domainjoined="));
224 #if defined(GOOGLE_CHROME_BUILD)
225 // Check the Omaha updater state data in the request.
226 EXPECT_NE(string::npos, request.find("<updater "));
227 EXPECT_NE(string::npos, request.find(" name=\"Omaha\" "));
228 #endif // GOOGLE_CHROME_BUILD
229 #endif // OS_WINDOWS
223 } 230 }
224 231
225 // Tests that an invalid "ap" is not serialized. 232 // Tests that an invalid "ap" is not serialized.
226 TEST_F(UpdateCheckerTest, UpdateCheckInvalidAp) { 233 TEST_F(UpdateCheckerTest, UpdateCheckInvalidAp) {
227 EXPECT_TRUE(post_interceptor_->ExpectRequest( 234 EXPECT_TRUE(post_interceptor_->ExpectRequest(
228 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); 235 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml")));
229 236
230 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); 237 update_checker_ = UpdateChecker::Create(config_, metadata_.get());
231 238
232 std::unique_ptr<CrxUpdateItem> item = BuildCrxUpdateItem(); 239 std::unique_ptr<CrxUpdateItem> item = BuildCrxUpdateItem();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 506 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
500 base::Unretained(this))); 507 base::Unretained(this)));
501 RunThreads(); 508 RunThreads();
502 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[3].find( 509 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[3].find(
503 std::string("<app appid=\"") + kUpdateItemId + 510 std::string("<app appid=\"") + kUpdateItemId +
504 "\" version=\"0.9\">" 511 "\" version=\"0.9\">"
505 "<updatecheck/>")); 512 "<updatecheck/>"));
506 } 513 }
507 514
508 } // namespace update_client 515 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/update_checker.cc ('k') | components/update_client/updater_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698