| 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 "components/update_client/update_checker.h" | 5 #include "components/update_client/update_checker.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); | 168 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
| 169 | 169 |
| 170 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 170 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 171 | 171 |
| 172 CrxUpdateItem item(BuildCrxUpdateItem()); | 172 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 173 item.component.installer_attributes["ap"] = "some_ap"; | 173 item.component.installer_attributes["ap"] = "some_ap"; |
| 174 std::vector<CrxUpdateItem*> items_to_check; | 174 std::vector<CrxUpdateItem*> items_to_check; |
| 175 items_to_check.push_back(&item); | 175 items_to_check.push_back(&item); |
| 176 | 176 |
| 177 update_checker_->CheckForUpdates( | 177 update_checker_->CheckForUpdates( |
| 178 items_to_check, "extra=\"params\"", | 178 items_to_check, "extra=\"params\"", true, |
| 179 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 179 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 180 base::Unretained(this))); | 180 base::Unretained(this))); |
| 181 | 181 |
| 182 RunThreads(); | 182 RunThreads(); |
| 183 | 183 |
| 184 EXPECT_EQ(1, post_interceptor_->GetHitCount()) | 184 EXPECT_EQ(1, post_interceptor_->GetHitCount()) |
| 185 << post_interceptor_->GetRequestsAsString(); | 185 << post_interceptor_->GetRequestsAsString(); |
| 186 ASSERT_EQ(1, post_interceptor_->GetCount()) | 186 ASSERT_EQ(1, post_interceptor_->GetCount()) |
| 187 << post_interceptor_->GetRequestsAsString(); | 187 << post_interceptor_->GetRequestsAsString(); |
| 188 | 188 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 219 | 219 |
| 220 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 220 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 221 | 221 |
| 222 CrxUpdateItem item(BuildCrxUpdateItem()); | 222 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 223 // Make "ap" too long. | 223 // Make "ap" too long. |
| 224 item.component.installer_attributes["ap"] = std::string(257, 'a'); | 224 item.component.installer_attributes["ap"] = std::string(257, 'a'); |
| 225 std::vector<CrxUpdateItem*> items_to_check; | 225 std::vector<CrxUpdateItem*> items_to_check; |
| 226 items_to_check.push_back(&item); | 226 items_to_check.push_back(&item); |
| 227 | 227 |
| 228 update_checker_->CheckForUpdates( | 228 update_checker_->CheckForUpdates( |
| 229 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 229 items_to_check, "", true, |
| 230 base::Unretained(this))); | 230 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 231 base::Unretained(this))); |
| 231 | 232 |
| 232 RunThreads(); | 233 RunThreads(); |
| 233 | 234 |
| 234 EXPECT_NE( | 235 EXPECT_NE( |
| 235 string::npos, | 236 string::npos, |
| 236 post_interceptor_->GetRequests()[0].find( | 237 post_interceptor_->GetRequests()[0].find( |
| 237 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" " | 238 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" " |
| 238 "brand=\"TEST\"><updatecheck/><ping rd=\"-2\" ")); | 239 "brand=\"TEST\"><updatecheck/><ping rd=\"-2\" ")); |
| 239 EXPECT_NE(string::npos, | 240 EXPECT_NE(string::npos, |
| 240 post_interceptor_->GetRequests()[0].find( | 241 post_interceptor_->GetRequests()[0].find( |
| 241 "<packages><package fp=\"fp1\"/></packages></app>")); | 242 "<packages><package fp=\"fp1\"/></packages></app>")); |
| 242 } | 243 } |
| 243 | 244 |
| 244 TEST_F(UpdateCheckerTest, UpdateCheckSuccessNoBrand) { | 245 TEST_F(UpdateCheckerTest, UpdateCheckSuccessNoBrand) { |
| 245 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 246 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
| 246 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); | 247 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
| 247 | 248 |
| 248 config_->SetBrand("TOOLONG"); // Sets an invalid brand code. | 249 config_->SetBrand("TOOLONG"); // Sets an invalid brand code. |
| 249 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 250 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 250 | 251 |
| 251 CrxUpdateItem item(BuildCrxUpdateItem()); | 252 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 252 std::vector<CrxUpdateItem*> items_to_check; | 253 std::vector<CrxUpdateItem*> items_to_check; |
| 253 items_to_check.push_back(&item); | 254 items_to_check.push_back(&item); |
| 254 | 255 |
| 255 update_checker_->CheckForUpdates( | 256 update_checker_->CheckForUpdates( |
| 256 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 257 items_to_check, "", true, |
| 257 base::Unretained(this))); | 258 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 259 base::Unretained(this))); |
| 258 | 260 |
| 259 RunThreads(); | 261 RunThreads(); |
| 260 | 262 |
| 261 EXPECT_NE( | 263 EXPECT_NE( |
| 262 string::npos, | 264 string::npos, |
| 263 post_interceptor_->GetRequests()[0].find( | 265 post_interceptor_->GetRequests()[0].find( |
| 264 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" | 266 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" |
| 265 "<updatecheck/><ping rd=\"-2\" ")); | 267 "<updatecheck/><ping rd=\"-2\" ")); |
| 266 EXPECT_NE(string::npos, | 268 EXPECT_NE(string::npos, |
| 267 post_interceptor_->GetRequests()[0].find( | 269 post_interceptor_->GetRequests()[0].find( |
| 268 "<packages><package fp=\"fp1\"/></packages></app>")); | 270 "<packages><package fp=\"fp1\"/></packages></app>")); |
| 269 } | 271 } |
| 270 | 272 |
| 271 // Simulates a 403 server response error. | 273 // Simulates a 403 server response error. |
| 272 TEST_F(UpdateCheckerTest, UpdateCheckError) { | 274 TEST_F(UpdateCheckerTest, UpdateCheckError) { |
| 273 EXPECT_TRUE( | 275 EXPECT_TRUE( |
| 274 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403)); | 276 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403)); |
| 275 | 277 |
| 276 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 278 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 277 | 279 |
| 278 CrxUpdateItem item(BuildCrxUpdateItem()); | 280 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 279 std::vector<CrxUpdateItem*> items_to_check; | 281 std::vector<CrxUpdateItem*> items_to_check; |
| 280 items_to_check.push_back(&item); | 282 items_to_check.push_back(&item); |
| 281 | 283 |
| 282 update_checker_->CheckForUpdates( | 284 update_checker_->CheckForUpdates( |
| 283 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 285 items_to_check, "", true, |
| 284 base::Unretained(this))); | 286 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 287 base::Unretained(this))); |
| 285 RunThreads(); | 288 RunThreads(); |
| 286 | 289 |
| 287 EXPECT_EQ(1, post_interceptor_->GetHitCount()) | 290 EXPECT_EQ(1, post_interceptor_->GetHitCount()) |
| 288 << post_interceptor_->GetRequestsAsString(); | 291 << post_interceptor_->GetRequestsAsString(); |
| 289 EXPECT_EQ(1, post_interceptor_->GetCount()) | 292 EXPECT_EQ(1, post_interceptor_->GetCount()) |
| 290 << post_interceptor_->GetRequestsAsString(); | 293 << post_interceptor_->GetRequestsAsString(); |
| 291 | 294 |
| 292 EXPECT_EQ(403, error_); | 295 EXPECT_EQ(403, error_); |
| 293 EXPECT_EQ(0ul, results_.list.size()); | 296 EXPECT_EQ(0ul, results_.list.size()); |
| 294 } | 297 } |
| 295 | 298 |
| 296 TEST_F(UpdateCheckerTest, UpdateCheckDownloadPreference) { | 299 TEST_F(UpdateCheckerTest, UpdateCheckDownloadPreference) { |
| 297 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 300 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
| 298 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); | 301 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
| 299 | 302 |
| 300 config_->SetDownloadPreference(string("cacheable")); | 303 config_->SetDownloadPreference(string("cacheable")); |
| 301 | 304 |
| 302 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 305 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 303 | 306 |
| 304 CrxUpdateItem item(BuildCrxUpdateItem()); | 307 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 305 std::vector<CrxUpdateItem*> items_to_check; | 308 std::vector<CrxUpdateItem*> items_to_check; |
| 306 items_to_check.push_back(&item); | 309 items_to_check.push_back(&item); |
| 307 | 310 |
| 308 update_checker_->CheckForUpdates( | 311 update_checker_->CheckForUpdates( |
| 309 items_to_check, "extra=\"params\"", | 312 items_to_check, "extra=\"params\"", true, |
| 310 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 313 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 311 base::Unretained(this))); | 314 base::Unretained(this))); |
| 312 | 315 |
| 313 RunThreads(); | 316 RunThreads(); |
| 314 | 317 |
| 315 // The request must contain dlpref="cacheable". | 318 // The request must contain dlpref="cacheable". |
| 316 EXPECT_NE(string::npos, | 319 EXPECT_NE(string::npos, |
| 317 post_interceptor_->GetRequests()[0].find(" dlpref=\"cacheable\"")); | 320 post_interceptor_->GetRequests()[0].find(" dlpref=\"cacheable\"")); |
| 318 } | 321 } |
| 319 | 322 |
| 320 // This test is checking that an update check signed with CUP fails, since there | 323 // This test is checking that an update check signed with CUP fails, since there |
| 321 // is currently no entity that can respond with a valid signed response. | 324 // is currently no entity that can respond with a valid signed response. |
| 322 // A proper CUP test requires network mocks, which are not available now. | 325 // A proper CUP test requires network mocks, which are not available now. |
| 323 TEST_F(UpdateCheckerTest, UpdateCheckCupError) { | 326 TEST_F(UpdateCheckerTest, UpdateCheckCupError) { |
| 324 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 327 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
| 325 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); | 328 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
| 326 | 329 |
| 327 config_->SetEnabledCupSigning(true); | 330 config_->SetEnabledCupSigning(true); |
| 328 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 331 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 329 | 332 |
| 330 CrxUpdateItem item(BuildCrxUpdateItem()); | 333 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 331 std::vector<CrxUpdateItem*> items_to_check; | 334 std::vector<CrxUpdateItem*> items_to_check; |
| 332 items_to_check.push_back(&item); | 335 items_to_check.push_back(&item); |
| 333 | 336 |
| 334 update_checker_->CheckForUpdates( | 337 update_checker_->CheckForUpdates( |
| 335 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 338 items_to_check, "", true, |
| 336 base::Unretained(this))); | 339 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 340 base::Unretained(this))); |
| 337 | 341 |
| 338 RunThreads(); | 342 RunThreads(); |
| 339 | 343 |
| 340 EXPECT_EQ(1, post_interceptor_->GetHitCount()) | 344 EXPECT_EQ(1, post_interceptor_->GetHitCount()) |
| 341 << post_interceptor_->GetRequestsAsString(); | 345 << post_interceptor_->GetRequestsAsString(); |
| 342 ASSERT_EQ(1, post_interceptor_->GetCount()) | 346 ASSERT_EQ(1, post_interceptor_->GetCount()) |
| 343 << post_interceptor_->GetRequestsAsString(); | 347 << post_interceptor_->GetRequestsAsString(); |
| 344 | 348 |
| 345 // Sanity check the request. | 349 // Sanity check the request. |
| 346 EXPECT_NE( | 350 EXPECT_NE( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 363 config_->SetUpdateCheckUrl(GURL("http:\\foo\bar")); | 367 config_->SetUpdateCheckUrl(GURL("http:\\foo\bar")); |
| 364 | 368 |
| 365 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 369 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 366 | 370 |
| 367 CrxUpdateItem item(BuildCrxUpdateItem()); | 371 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 368 item.component.requires_network_encryption = true; | 372 item.component.requires_network_encryption = true; |
| 369 std::vector<CrxUpdateItem*> items_to_check; | 373 std::vector<CrxUpdateItem*> items_to_check; |
| 370 items_to_check.push_back(&item); | 374 items_to_check.push_back(&item); |
| 371 | 375 |
| 372 update_checker_->CheckForUpdates( | 376 update_checker_->CheckForUpdates( |
| 373 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 377 items_to_check, "", true, |
| 374 base::Unretained(this))); | 378 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 379 base::Unretained(this))); |
| 375 RunThreads(); | 380 RunThreads(); |
| 376 | 381 |
| 377 EXPECT_EQ(-1, error_); | 382 EXPECT_EQ(-1, error_); |
| 378 EXPECT_EQ(0u, results_.list.size()); | 383 EXPECT_EQ(0u, results_.list.size()); |
| 379 } | 384 } |
| 380 | 385 |
| 381 // Tests that the PersistedData will get correctly update and reserialize | 386 // Tests that the PersistedData will get correctly update and reserialize |
| 382 // the elapsed_days value. | 387 // the elapsed_days value. |
| 383 TEST_F(UpdateCheckerTest, UpdateCheckDateLastRollCall) { | 388 TEST_F(UpdateCheckerTest, UpdateCheckDateLastRollCall) { |
| 384 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 389 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
| 385 new PartialMatch("updatecheck"), test_file("updatecheck_reply_4.xml"))); | 390 new PartialMatch("updatecheck"), test_file("updatecheck_reply_4.xml"))); |
| 386 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 391 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
| 387 new PartialMatch("updatecheck"), test_file("updatecheck_reply_4.xml"))); | 392 new PartialMatch("updatecheck"), test_file("updatecheck_reply_4.xml"))); |
| 388 | 393 |
| 389 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 394 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 390 | 395 |
| 391 CrxUpdateItem item(BuildCrxUpdateItem()); | 396 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 392 std::vector<CrxUpdateItem*> items_to_check; | 397 std::vector<CrxUpdateItem*> items_to_check; |
| 393 items_to_check.push_back(&item); | 398 items_to_check.push_back(&item); |
| 394 | 399 |
| 395 // Do two update-checks. | 400 // Do two update-checks. |
| 396 update_checker_->CheckForUpdates( | 401 update_checker_->CheckForUpdates( |
| 397 items_to_check, "extra=\"params\"", | 402 items_to_check, "extra=\"params\"", true, |
| 398 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 403 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 399 base::Unretained(this))); | 404 base::Unretained(this))); |
| 400 RunThreads(); | 405 RunThreads(); |
| 401 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 406 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 402 update_checker_->CheckForUpdates( | 407 update_checker_->CheckForUpdates( |
| 403 items_to_check, "extra=\"params\"", | 408 items_to_check, "extra=\"params\"", true, |
| 404 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 409 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 405 base::Unretained(this))); | 410 base::Unretained(this))); |
| 406 RunThreads(); | 411 RunThreads(); |
| 407 | 412 |
| 408 EXPECT_EQ(2, post_interceptor_->GetHitCount()) | 413 EXPECT_EQ(2, post_interceptor_->GetHitCount()) |
| 409 << post_interceptor_->GetRequestsAsString(); | 414 << post_interceptor_->GetRequestsAsString(); |
| 410 ASSERT_EQ(2, post_interceptor_->GetCount()) | 415 ASSERT_EQ(2, post_interceptor_->GetCount()) |
| 411 << post_interceptor_->GetRequestsAsString(); | 416 << post_interceptor_->GetRequestsAsString(); |
| 412 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( | 417 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( |
| 413 "<ping rd=\"-2\" ping_freshness=")); | 418 "<ping rd=\"-2\" ping_freshness=")); |
| 414 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[1].find( | 419 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[1].find( |
| 415 "<ping rd=\"3383\" ping_freshness=")); | 420 "<ping rd=\"3383\" ping_freshness=")); |
| 416 } | 421 } |
| 417 | 422 |
| 418 TEST_F(UpdateCheckerTest, UpdateCheckUpdateDisabled) { | 423 TEST_F(UpdateCheckerTest, UpdateCheckUpdateDisabled) { |
| 419 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 424 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
| 420 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); | 425 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
| 421 | 426 |
| 422 config_->SetBrand(""); | 427 config_->SetBrand(""); |
| 423 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 428 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 424 | 429 |
| 425 CrxUpdateItem item(BuildCrxUpdateItem()); | 430 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 426 | 431 |
| 427 // Tests the scenario where: | 432 // Tests the scenario where: |
| 428 // * the component does not support group policies. | 433 // * the component does not support group policies. |
| 429 // * the component updates are disabled. | 434 // * the component updates are disabled. |
| 430 // Expects the group policy to be ignored and the update check to not | 435 // Expects the group policy to be ignored and the update check to not |
| 431 // include the "updatedisabled" attribute. | 436 // include the "updatedisabled" attribute. |
| 432 EXPECT_FALSE(item.component.supports_group_policy_enable_component_updates); | 437 EXPECT_FALSE(item.component.supports_group_policy_enable_component_updates); |
| 433 config_->SetEnabledComponentUpdates(false); | |
| 434 std::vector<CrxUpdateItem*> items_to_check; | 438 std::vector<CrxUpdateItem*> items_to_check; |
| 435 items_to_check.push_back(&item); | 439 items_to_check.push_back(&item); |
| 436 update_checker_->CheckForUpdates( | 440 update_checker_->CheckForUpdates( |
| 437 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 441 items_to_check, "", false, |
| 438 base::Unretained(this))); | 442 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 443 base::Unretained(this))); |
| 439 RunThreads(); | 444 RunThreads(); |
| 440 EXPECT_NE( | 445 EXPECT_NE( |
| 441 string::npos, | 446 string::npos, |
| 442 post_interceptor_->GetRequests()[0].find( | 447 post_interceptor_->GetRequests()[0].find( |
| 443 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" | 448 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" |
| 444 "<updatecheck/>")); | 449 "<updatecheck/>")); |
| 445 | 450 |
| 446 // Tests the scenario where: | 451 // Tests the scenario where: |
| 447 // * the component supports group policies. | 452 // * the component supports group policies. |
| 448 // * the component updates are disabled. | 453 // * the component updates are disabled. |
| 449 // Expects the update check to include the "updatedisabled" attribute. | 454 // Expects the update check to include the "updatedisabled" attribute. |
| 450 item.component.supports_group_policy_enable_component_updates = true; | 455 item.component.supports_group_policy_enable_component_updates = true; |
| 451 config_->SetEnabledComponentUpdates(false); | |
| 452 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 456 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 453 update_checker_->CheckForUpdates( | 457 update_checker_->CheckForUpdates( |
| 454 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 458 items_to_check, "", false, |
| 455 base::Unretained(this))); | 459 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 460 base::Unretained(this))); |
| 456 RunThreads(); | 461 RunThreads(); |
| 457 EXPECT_NE( | 462 EXPECT_NE( |
| 458 string::npos, | 463 string::npos, |
| 459 post_interceptor_->GetRequests()[1].find( | 464 post_interceptor_->GetRequests()[1].find( |
| 460 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" | 465 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" |
| 461 "<updatecheck updatedisabled=\"true\"/>")); | 466 "<updatecheck updatedisabled=\"true\"/>")); |
| 462 | 467 |
| 463 // Tests the scenario where: | 468 // Tests the scenario where: |
| 464 // * the component does not support group policies. | 469 // * the component does not support group policies. |
| 465 // * the component updates are enabled. | 470 // * the component updates are enabled. |
| 466 // Expects the update check to not include the "updatedisabled" attribute. | 471 // Expects the update check to not include the "updatedisabled" attribute. |
| 467 item.component.supports_group_policy_enable_component_updates = false; | 472 item.component.supports_group_policy_enable_component_updates = false; |
| 468 config_->SetEnabledComponentUpdates(true); | |
| 469 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 473 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 470 update_checker_->CheckForUpdates( | 474 update_checker_->CheckForUpdates( |
| 471 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 475 items_to_check, "", true, |
| 472 base::Unretained(this))); | 476 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 477 base::Unretained(this))); |
| 473 RunThreads(); | 478 RunThreads(); |
| 474 EXPECT_NE( | 479 EXPECT_NE( |
| 475 string::npos, | 480 string::npos, |
| 476 post_interceptor_->GetRequests()[2].find( | 481 post_interceptor_->GetRequests()[2].find( |
| 477 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" | 482 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" |
| 478 "<updatecheck/>")); | 483 "<updatecheck/>")); |
| 479 | 484 |
| 480 // Tests the scenario where: | 485 // Tests the scenario where: |
| 481 // * the component supports group policies. | 486 // * the component supports group policies. |
| 482 // * the component updates are enabled. | 487 // * the component updates are enabled. |
| 483 // Expects the update check to not include the "updatedisabled" attribute. | 488 // Expects the update check to not include the "updatedisabled" attribute. |
| 484 item.component.supports_group_policy_enable_component_updates = true; | 489 item.component.supports_group_policy_enable_component_updates = true; |
| 485 config_->SetEnabledComponentUpdates(true); | |
| 486 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); | 490 update_checker_ = UpdateChecker::Create(config_, metadata_.get()); |
| 487 update_checker_->CheckForUpdates( | 491 update_checker_->CheckForUpdates( |
| 488 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 492 items_to_check, "", true, |
| 489 base::Unretained(this))); | 493 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 494 base::Unretained(this))); |
| 490 RunThreads(); | 495 RunThreads(); |
| 491 EXPECT_NE( | 496 EXPECT_NE( |
| 492 string::npos, | 497 string::npos, |
| 493 post_interceptor_->GetRequests()[3].find( | 498 post_interceptor_->GetRequests()[3].find( |
| 494 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" | 499 "<app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" |
| 495 "<updatecheck/>")); | 500 "<updatecheck/>")); |
| 496 } | 501 } |
| 497 | 502 |
| 498 } // namespace update_client | 503 } // namespace update_client |
| OLD | NEW |