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