OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "chrome/browser/component_updater/test/component_updater_service_unitte
st.h" | 5 #include "chrome/browser/component_updater/test/component_updater_service_unitte
st.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 // Test the protocol version is correct and the extra request attributes | 469 // Test the protocol version is correct and the extra request attributes |
470 // are included in the request. | 470 // are included in the request. |
471 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( | 471 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( |
472 "request protocol=\"3.0\" extra=\"foo\"")) | 472 "request protocol=\"3.0\" extra=\"foo\"")) |
473 << post_interceptor_->GetRequestsAsString(); | 473 << post_interceptor_->GetRequestsAsString(); |
474 | 474 |
475 // Tokenize the request string to look for specific attributes, which | 475 // Tokenize the request string to look for specific attributes, which |
476 // are important for backward compatibility with the version v2 of the update | 476 // are important for backward compatibility with the version v2 of the update |
477 // protocol. In this case, inspect the <request>, which is the first element | 477 // protocol. In this case, inspect the <request>, which is the first element |
478 // after the xml declaration of the update request body. | 478 // after the xml declaration of the update request body. |
479 // Expect to find the |os| and the |arch| attributes: | 479 // Expect to find the |os|, |arch|, |prodchannel|, and |prodversion| |
| 480 // attributes: |
480 // <?xml version="1.0" encoding="UTF-8"?> | 481 // <?xml version="1.0" encoding="UTF-8"?> |
481 // <request...os=...arch=...> | 482 // <request... os=... arch=... prodchannel=... prodversion=...> |
482 // ... | 483 // ... |
483 // </request> | 484 // </request> |
484 const std::string update_request(post_interceptor_->GetRequests()[0]); | 485 const std::string update_request(post_interceptor_->GetRequests()[0]); |
485 std::vector<base::StringPiece> elements; | 486 std::vector<base::StringPiece> elements; |
486 Tokenize(update_request, "<>", &elements); | 487 Tokenize(update_request, "<>", &elements); |
487 EXPECT_NE(string::npos, elements[1].find("os=")); | 488 EXPECT_NE(string::npos, elements[1].find(" os=")); |
488 EXPECT_NE(string::npos, elements[1].find("arch=")); | 489 EXPECT_NE(string::npos, elements[1].find(" arch=")); |
| 490 EXPECT_NE(string::npos, elements[1].find(" prodchannel=")); |
| 491 EXPECT_NE(string::npos, elements[1].find(" prodversion=")); |
489 | 492 |
490 component_updater()->Stop(); | 493 component_updater()->Stop(); |
491 } | 494 } |
492 | 495 |
493 // This test checks that the "prodversionmin" value is handled correctly. In | 496 // This test checks that the "prodversionmin" value is handled correctly. In |
494 // particular there should not be an install because the minimum product | 497 // particular there should not be an install because the minimum product |
495 // version is much higher than of chrome. | 498 // version is much higher than of chrome. |
496 TEST_F(ComponentUpdaterTest, ProdVersionCheck) { | 499 TEST_F(ComponentUpdaterTest, ProdVersionCheck) { |
497 EXPECT_TRUE(post_interceptor_->ExpectRequest(new PartialMatch( | 500 EXPECT_TRUE(post_interceptor_->ExpectRequest(new PartialMatch( |
498 "updatecheck"), test_file("updatecheck_reply_2.xml"))); | 501 "updatecheck"), test_file("updatecheck_reply_2.xml"))); |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 EXPECT_EQ(1, post_interceptor_->GetHitCount()); | 1396 EXPECT_EQ(1, post_interceptor_->GetHitCount()); |
1394 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); | 1397 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); |
1395 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); | 1398 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); |
1396 | 1399 |
1397 component_updater()->Stop(); | 1400 component_updater()->Stop(); |
1398 } | 1401 } |
1399 | 1402 |
1400 | 1403 |
1401 } // namespace component_updater | 1404 } // namespace component_updater |
1402 | 1405 |
OLD | NEW |