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

Side by Side Diff: components/update_client/update_checker_unittest.cc

Issue 1861383004: Add module for counting date-last-roll-call and persisting those counts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another test fix. Created 4 years, 8 months 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/update_client.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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/version.h" 14 #include "base/version.h"
15 #include "components/prefs/testing_pref_service.h"
15 #include "components/update_client/crx_update_item.h" 16 #include "components/update_client/crx_update_item.h"
17 #include "components/update_client/persisted_data.h"
16 #include "components/update_client/test_configurator.h" 18 #include "components/update_client/test_configurator.h"
17 #include "components/update_client/update_checker.h" 19 #include "components/update_client/update_checker.h"
18 #include "components/update_client/url_request_post_interceptor.h" 20 #include "components/update_client/url_request_post_interceptor.h"
19 #include "net/url_request/url_request_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
22 24
23 using std::string; 25 using std::string;
24 26
25 namespace update_client { 27 namespace update_client {
(...skipping 26 matching lines...) Expand all
52 int retry_after_sec); 54 int retry_after_sec);
53 55
54 protected: 56 protected:
55 void Quit(); 57 void Quit();
56 void RunThreads(); 58 void RunThreads();
57 void RunThreadsUntilIdle(); 59 void RunThreadsUntilIdle();
58 60
59 CrxUpdateItem BuildCrxUpdateItem(); 61 CrxUpdateItem BuildCrxUpdateItem();
60 62
61 scoped_refptr<TestConfigurator> config_; 63 scoped_refptr<TestConfigurator> config_;
64 std::unique_ptr<TestingPrefServiceSimple> pref_;
65 std::unique_ptr<PersistedData> metadata_;
62 66
63 scoped_ptr<UpdateChecker> update_checker_; 67 scoped_ptr<UpdateChecker> update_checker_;
64 68
65 scoped_ptr<InterceptorFactory> interceptor_factory_; 69 scoped_ptr<InterceptorFactory> interceptor_factory_;
66 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory. 70 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory.
67 71
68 int error_; 72 int error_;
69 UpdateResponse::Results results_; 73 UpdateResponse::Results results_;
70 74
71 private: 75 private:
72 base::MessageLoopForIO loop_; 76 base::MessageLoopForIO loop_;
73 base::Closure quit_closure_; 77 base::Closure quit_closure_;
74 78
75 DISALLOW_COPY_AND_ASSIGN(UpdateCheckerTest); 79 DISALLOW_COPY_AND_ASSIGN(UpdateCheckerTest);
76 }; 80 };
77 81
78 UpdateCheckerTest::UpdateCheckerTest() : post_interceptor_(NULL), error_(0) { 82 UpdateCheckerTest::UpdateCheckerTest() : post_interceptor_(NULL), error_(0) {
79 } 83 }
80 84
81 UpdateCheckerTest::~UpdateCheckerTest() { 85 UpdateCheckerTest::~UpdateCheckerTest() {
82 } 86 }
83 87
84 void UpdateCheckerTest::SetUp() { 88 void UpdateCheckerTest::SetUp() {
85 config_ = new TestConfigurator(base::ThreadTaskRunnerHandle::Get(), 89 config_ = new TestConfigurator(base::ThreadTaskRunnerHandle::Get(),
86 base::ThreadTaskRunnerHandle::Get()); 90 base::ThreadTaskRunnerHandle::Get());
91 pref_.reset(new TestingPrefServiceSimple());
92 PersistedData::RegisterPrefs(pref_->registry());
93 metadata_.reset(new PersistedData(pref_.get()));
87 interceptor_factory_.reset( 94 interceptor_factory_.reset(
88 new InterceptorFactory(base::ThreadTaskRunnerHandle::Get())); 95 new InterceptorFactory(base::ThreadTaskRunnerHandle::Get()));
89 post_interceptor_ = interceptor_factory_->CreateInterceptor(); 96 post_interceptor_ = interceptor_factory_->CreateInterceptor();
90 EXPECT_TRUE(post_interceptor_); 97 EXPECT_TRUE(post_interceptor_);
91 98
92 update_checker_.reset(); 99 update_checker_.reset();
93 100
94 error_ = 0; 101 error_ = 0;
95 results_ = UpdateResponse::Results(); 102 results_ = UpdateResponse::Results();
96 } 103 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 crx_update_item.id = "jebgalgnebhfojomionfpkfelancnnkf"; 158 crx_update_item.id = "jebgalgnebhfojomionfpkfelancnnkf";
152 crx_update_item.component = crx_component; 159 crx_update_item.component = crx_component;
153 160
154 return crx_update_item; 161 return crx_update_item;
155 } 162 }
156 163
157 TEST_F(UpdateCheckerTest, UpdateCheckSuccess) { 164 TEST_F(UpdateCheckerTest, UpdateCheckSuccess) {
158 EXPECT_TRUE(post_interceptor_->ExpectRequest( 165 EXPECT_TRUE(post_interceptor_->ExpectRequest(
159 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); 166 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml")));
160 167
161 update_checker_ = UpdateChecker::Create(config_); 168 update_checker_ = UpdateChecker::Create(config_, *metadata_);
162 169
163 CrxUpdateItem item(BuildCrxUpdateItem()); 170 CrxUpdateItem item(BuildCrxUpdateItem());
164 item.component.ap = "some_ap"; 171 item.component.ap = "some_ap";
165 std::vector<CrxUpdateItem*> items_to_check; 172 std::vector<CrxUpdateItem*> items_to_check;
166 items_to_check.push_back(&item); 173 items_to_check.push_back(&item);
167 174
168 update_checker_->CheckForUpdates( 175 update_checker_->CheckForUpdates(
169 items_to_check, "extra=\"params\"", 176 items_to_check, "extra=\"params\"",
170 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 177 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
171 base::Unretained(this))); 178 base::Unretained(this)));
172 179
173 RunThreads(); 180 RunThreads();
174 181
175 EXPECT_EQ(1, post_interceptor_->GetHitCount()) 182 EXPECT_EQ(1, post_interceptor_->GetHitCount())
176 << post_interceptor_->GetRequestsAsString(); 183 << post_interceptor_->GetRequestsAsString();
177 ASSERT_EQ(1, post_interceptor_->GetCount()) 184 ASSERT_EQ(1, post_interceptor_->GetCount())
178 << post_interceptor_->GetRequestsAsString(); 185 << post_interceptor_->GetRequestsAsString();
179 186
180 // Sanity check the request. 187 // Sanity check the request.
181 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( 188 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find(
182 "request protocol=\"3.0\" extra=\"params\"")); 189 "request protocol=\"3.0\" extra=\"params\""));
183 // The request must not contain any "dlpref" in the default case. 190 // The request must not contain any "dlpref" in the default case.
184 EXPECT_EQ(string::npos, 191 EXPECT_EQ(string::npos,
185 post_interceptor_->GetRequests()[0].find(" dlpref=\"")); 192 post_interceptor_->GetRequests()[0].find(" dlpref=\""));
186 EXPECT_NE( 193 EXPECT_NE(
187 string::npos, 194 string::npos,
188 post_interceptor_->GetRequests()[0].find( 195 post_interceptor_->GetRequests()[0].find(
189 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" " 196 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" "
190 "brand=\"TEST\" ap=\"some_ap\"><updatecheck />" 197 "brand=\"TEST\" ap=\"some_ap\"><updatecheck /><ping rd=\"-2\" />"
191 "<packages><package fp=\"fp1\"/></packages></app>")); 198 "<packages><package fp=\"fp1\"/></packages></app>"));
192 199
193 EXPECT_NE(string::npos, 200 EXPECT_NE(string::npos,
194 post_interceptor_->GetRequests()[0].find("<hw physmemory=")); 201 post_interceptor_->GetRequests()[0].find("<hw physmemory="));
195 202
196 // Sanity check the arguments of the callback after parsing. 203 // Sanity check the arguments of the callback after parsing.
197 EXPECT_EQ(0, error_); 204 EXPECT_EQ(0, error_);
198 EXPECT_EQ(1ul, results_.list.size()); 205 EXPECT_EQ(1ul, results_.list.size());
199 EXPECT_STREQ("jebgalgnebhfojomionfpkfelancnnkf", 206 EXPECT_STREQ("jebgalgnebhfojomionfpkfelancnnkf",
200 results_.list[0].extension_id.c_str()); 207 results_.list[0].extension_id.c_str());
201 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str()); 208 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str());
202 } 209 }
203 210
204 // Tests that an invalid "ap" is not serialized. 211 // Tests that an invalid "ap" is not serialized.
205 TEST_F(UpdateCheckerTest, UpdateCheckInvalidAp) { 212 TEST_F(UpdateCheckerTest, UpdateCheckInvalidAp) {
206 EXPECT_TRUE(post_interceptor_->ExpectRequest( 213 EXPECT_TRUE(post_interceptor_->ExpectRequest(
207 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); 214 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml")));
208 215
209 update_checker_ = UpdateChecker::Create(config_); 216 update_checker_ = UpdateChecker::Create(config_, *metadata_);
210 217
211 CrxUpdateItem item(BuildCrxUpdateItem()); 218 CrxUpdateItem item(BuildCrxUpdateItem());
212 item.component.ap = std::string(257, 'a'); // Too long. 219 item.component.ap = std::string(257, 'a'); // Too long.
213 std::vector<CrxUpdateItem*> items_to_check; 220 std::vector<CrxUpdateItem*> items_to_check;
214 items_to_check.push_back(&item); 221 items_to_check.push_back(&item);
215 222
216 update_checker_->CheckForUpdates( 223 update_checker_->CheckForUpdates(
217 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 224 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
218 base::Unretained(this))); 225 base::Unretained(this)));
219 226
220 RunThreads(); 227 RunThreads();
221 228
222 EXPECT_NE( 229 EXPECT_NE(
223 string::npos, 230 string::npos,
224 post_interceptor_->GetRequests()[0].find( 231 post_interceptor_->GetRequests()[0].find(
225 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" " 232 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" "
226 "brand=\"TEST\"><updatecheck />" 233 "brand=\"TEST\"><updatecheck /><ping rd=\"-2\" />"
227 "<packages><package fp=\"fp1\"/></packages></app>")); 234 "<packages><package fp=\"fp1\"/></packages></app>"));
228 } 235 }
229 236
230 TEST_F(UpdateCheckerTest, UpdateCheckSuccessNoBrand) { 237 TEST_F(UpdateCheckerTest, UpdateCheckSuccessNoBrand) {
231 EXPECT_TRUE(post_interceptor_->ExpectRequest( 238 EXPECT_TRUE(post_interceptor_->ExpectRequest(
232 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); 239 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml")));
233 240
234 config_->SetBrand("TOOLONG"); // Sets an invalid brand code. 241 config_->SetBrand("TOOLONG"); // Sets an invalid brand code.
235 update_checker_ = UpdateChecker::Create(config_); 242 update_checker_ = UpdateChecker::Create(config_, *metadata_);
236 243
237 CrxUpdateItem item(BuildCrxUpdateItem()); 244 CrxUpdateItem item(BuildCrxUpdateItem());
238 std::vector<CrxUpdateItem*> items_to_check; 245 std::vector<CrxUpdateItem*> items_to_check;
239 items_to_check.push_back(&item); 246 items_to_check.push_back(&item);
240 247
241 update_checker_->CheckForUpdates( 248 update_checker_->CheckForUpdates(
242 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 249 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
243 base::Unretained(this))); 250 base::Unretained(this)));
244 251
245 RunThreads(); 252 RunThreads();
246 253
247 EXPECT_NE( 254 EXPECT_NE(
248 string::npos, 255 string::npos,
249 post_interceptor_->GetRequests()[0].find( 256 post_interceptor_->GetRequests()[0].find(
250 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" 257 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">"
251 "<updatecheck /><packages><package fp=\"fp1\"/></packages></app>")); 258 "<updatecheck /><ping rd=\"-2\" /><packages><package fp=\"fp1\"/>"
259 "</packages></app>"));
252 } 260 }
253 261
254 // Simulates a 403 server response error. 262 // Simulates a 403 server response error.
255 TEST_F(UpdateCheckerTest, UpdateCheckError) { 263 TEST_F(UpdateCheckerTest, UpdateCheckError) {
256 EXPECT_TRUE( 264 EXPECT_TRUE(
257 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403)); 265 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403));
258 266
259 update_checker_ = UpdateChecker::Create(config_); 267 update_checker_ = UpdateChecker::Create(config_, *metadata_);
260 268
261 CrxUpdateItem item(BuildCrxUpdateItem()); 269 CrxUpdateItem item(BuildCrxUpdateItem());
262 std::vector<CrxUpdateItem*> items_to_check; 270 std::vector<CrxUpdateItem*> items_to_check;
263 items_to_check.push_back(&item); 271 items_to_check.push_back(&item);
264 272
265 update_checker_->CheckForUpdates( 273 update_checker_->CheckForUpdates(
266 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 274 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
267 base::Unretained(this))); 275 base::Unretained(this)));
268 RunThreads(); 276 RunThreads();
269 277
270 EXPECT_EQ(1, post_interceptor_->GetHitCount()) 278 EXPECT_EQ(1, post_interceptor_->GetHitCount())
271 << post_interceptor_->GetRequestsAsString(); 279 << post_interceptor_->GetRequestsAsString();
272 EXPECT_EQ(1, post_interceptor_->GetCount()) 280 EXPECT_EQ(1, post_interceptor_->GetCount())
273 << post_interceptor_->GetRequestsAsString(); 281 << post_interceptor_->GetRequestsAsString();
274 282
275 EXPECT_EQ(403, error_); 283 EXPECT_EQ(403, error_);
276 EXPECT_EQ(0ul, results_.list.size()); 284 EXPECT_EQ(0ul, results_.list.size());
277 } 285 }
278 286
279 TEST_F(UpdateCheckerTest, UpdateCheckDownloadPreference) { 287 TEST_F(UpdateCheckerTest, UpdateCheckDownloadPreference) {
280 EXPECT_TRUE(post_interceptor_->ExpectRequest( 288 EXPECT_TRUE(post_interceptor_->ExpectRequest(
281 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); 289 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml")));
282 290
283 config_->SetDownloadPreference(string("cacheable")); 291 config_->SetDownloadPreference(string("cacheable"));
284 292
285 update_checker_ = UpdateChecker::Create(config_); 293 update_checker_ = UpdateChecker::Create(config_, *metadata_);
286 294
287 CrxUpdateItem item(BuildCrxUpdateItem()); 295 CrxUpdateItem item(BuildCrxUpdateItem());
288 std::vector<CrxUpdateItem*> items_to_check; 296 std::vector<CrxUpdateItem*> items_to_check;
289 items_to_check.push_back(&item); 297 items_to_check.push_back(&item);
290 298
291 update_checker_->CheckForUpdates( 299 update_checker_->CheckForUpdates(
292 items_to_check, "extra=\"params\"", 300 items_to_check, "extra=\"params\"",
293 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 301 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
294 base::Unretained(this))); 302 base::Unretained(this)));
295 303
296 RunThreads(); 304 RunThreads();
297 305
298 // The request must contain dlpref="cacheable". 306 // The request must contain dlpref="cacheable".
299 EXPECT_NE(string::npos, 307 EXPECT_NE(string::npos,
300 post_interceptor_->GetRequests()[0].find(" dlpref=\"cacheable\"")); 308 post_interceptor_->GetRequests()[0].find(" dlpref=\"cacheable\""));
301 } 309 }
302 310
303 // This test is checking that an update check signed with CUP fails, since there 311 // This test is checking that an update check signed with CUP fails, since there
304 // is currently no entity that can respond with a valid signed response. 312 // is currently no entity that can respond with a valid signed response.
305 // A proper CUP test requires network mocks, which are not available now. 313 // A proper CUP test requires network mocks, which are not available now.
306 TEST_F(UpdateCheckerTest, UpdateCheckCupError) { 314 TEST_F(UpdateCheckerTest, UpdateCheckCupError) {
307 EXPECT_TRUE(post_interceptor_->ExpectRequest( 315 EXPECT_TRUE(post_interceptor_->ExpectRequest(
308 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); 316 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml")));
309 317
310 config_->SetUseCupSigning(true); 318 config_->SetUseCupSigning(true);
311 update_checker_ = UpdateChecker::Create(config_); 319 update_checker_ = UpdateChecker::Create(config_, *metadata_);
312 320
313 CrxUpdateItem item(BuildCrxUpdateItem()); 321 CrxUpdateItem item(BuildCrxUpdateItem());
314 std::vector<CrxUpdateItem*> items_to_check; 322 std::vector<CrxUpdateItem*> items_to_check;
315 items_to_check.push_back(&item); 323 items_to_check.push_back(&item);
316 324
317 update_checker_->CheckForUpdates( 325 update_checker_->CheckForUpdates(
318 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 326 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
319 base::Unretained(this))); 327 base::Unretained(this)));
320 328
321 RunThreads(); 329 RunThreads();
322 330
323 EXPECT_EQ(1, post_interceptor_->GetHitCount()) 331 EXPECT_EQ(1, post_interceptor_->GetHitCount())
324 << post_interceptor_->GetRequestsAsString(); 332 << post_interceptor_->GetRequestsAsString();
325 ASSERT_EQ(1, post_interceptor_->GetCount()) 333 ASSERT_EQ(1, post_interceptor_->GetCount())
326 << post_interceptor_->GetRequestsAsString(); 334 << post_interceptor_->GetRequestsAsString();
327 335
328 // Sanity check the request. 336 // Sanity check the request.
329 EXPECT_NE( 337 EXPECT_NE(
330 string::npos, 338 string::npos,
331 post_interceptor_->GetRequests()[0].find( 339 post_interceptor_->GetRequests()[0].find(
332 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" " 340 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" "
333 "brand=\"TEST\"><updatecheck />" 341 "brand=\"TEST\"><updatecheck /><ping rd=\"-2\" />"
334 "<packages><package fp=\"fp1\"/></packages></app>")); 342 "<packages><package fp=\"fp1\"/></packages></app>"));
335 343
336 // Expect an error since the response is not trusted. 344 // Expect an error since the response is not trusted.
337 EXPECT_EQ(-10000, error_); 345 EXPECT_EQ(-10000, error_);
338 EXPECT_EQ(0ul, results_.list.size()); 346 EXPECT_EQ(0ul, results_.list.size());
339 } 347 }
340 348
341 // Tests that the UpdateCheckers will not make an update check for a 349 // Tests that the UpdateCheckers will not make an update check for a
342 // component that requires encryption when the update check URL is unsecure. 350 // component that requires encryption when the update check URL is unsecure.
343 TEST_F(UpdateCheckerTest, UpdateCheckRequiresEncryptionError) { 351 TEST_F(UpdateCheckerTest, UpdateCheckRequiresEncryptionError) {
344 config_->SetUpdateCheckUrl(GURL("http:\\foo\bar")); 352 config_->SetUpdateCheckUrl(GURL("http:\\foo\bar"));
345 353
346 update_checker_ = UpdateChecker::Create(config_); 354 update_checker_ = UpdateChecker::Create(config_, *metadata_);
347 355
348 CrxUpdateItem item(BuildCrxUpdateItem()); 356 CrxUpdateItem item(BuildCrxUpdateItem());
349 item.component.requires_network_encryption = true; 357 item.component.requires_network_encryption = true;
350 std::vector<CrxUpdateItem*> items_to_check; 358 std::vector<CrxUpdateItem*> items_to_check;
351 items_to_check.push_back(&item); 359 items_to_check.push_back(&item);
352 360
353 update_checker_->CheckForUpdates( 361 update_checker_->CheckForUpdates(
354 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 362 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
355 base::Unretained(this))); 363 base::Unretained(this)));
356 RunThreads(); 364 RunThreads();
357 365
358 EXPECT_EQ(-1, error_); 366 EXPECT_EQ(-1, error_);
359 EXPECT_EQ(0u, results_.list.size()); 367 EXPECT_EQ(0u, results_.list.size());
360 } 368 }
361 369
370 // Tests that the PersistedData will get correctly update and reserialize
371 // the elapsed_days value.
372 TEST_F(UpdateCheckerTest, UpdateCheckDateLastRollCall) {
373 EXPECT_TRUE(post_interceptor_->ExpectRequest(
374 new PartialMatch("updatecheck"), test_file("updatecheck_reply_4.xml")));
375 EXPECT_TRUE(post_interceptor_->ExpectRequest(
376 new PartialMatch("updatecheck"), test_file("updatecheck_reply_4.xml")));
377
378 update_checker_ = UpdateChecker::Create(config_, *metadata_);
379
380 CrxUpdateItem item(BuildCrxUpdateItem());
381 std::vector<CrxUpdateItem*> items_to_check;
382 items_to_check.push_back(&item);
383
384 // Do two update-checks.
385 update_checker_->CheckForUpdates(
386 items_to_check, "extra=\"params\"",
387 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
388 base::Unretained(this)));
389 RunThreads();
390 update_checker_ = UpdateChecker::Create(config_, *metadata_);
391 update_checker_->CheckForUpdates(
392 items_to_check, "extra=\"params\"",
393 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
394 base::Unretained(this)));
395 RunThreads();
396
397 EXPECT_EQ(2, post_interceptor_->GetHitCount())
398 << post_interceptor_->GetRequestsAsString();
399 ASSERT_EQ(2, post_interceptor_->GetCount())
400 << post_interceptor_->GetRequestsAsString();
401 EXPECT_NE(string::npos,
402 post_interceptor_->GetRequests()[0].find("<ping rd=\"-2\" />"));
403 EXPECT_NE(string::npos,
404 post_interceptor_->GetRequests()[1].find("<ping rd=\"3383\" />"));
405 }
406
362 } // namespace update_client 407 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/update_checker.cc ('k') | components/update_client/update_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698