| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include <glib.h> | 8 #include <glib.h> |
| 9 | 9 |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 string::npos); | 539 string::npos); |
| 540 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), | 540 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), |
| 541 string::npos); | 541 string::npos); |
| 542 EXPECT_EQ(post_str.find("o:event"), string::npos); | 542 EXPECT_EQ(post_str.find("o:event"), string::npos); |
| 543 } | 543 } |
| 544 | 544 |
| 545 TEST(OmahaRequestActionTest, FormatUpdateCheckPrevVersionOutputTest) { | 545 TEST(OmahaRequestActionTest, FormatUpdateCheckPrevVersionOutputTest) { |
| 546 vector<char> post_data; | 546 vector<char> post_data; |
| 547 NiceMock<PrefsMock> prefs; | 547 NiceMock<PrefsMock> prefs; |
| 548 EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _)) | 548 EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _)) |
| 549 .WillOnce(DoAll(SetArgumentPointee<1>(string("1.2.3.4")), Return(true))); | 549 .WillOnce(DoAll(SetArgumentPointee<1>(string("1.2>3.4")), Return(true))); |
| 550 EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, "")) | 550 EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, "")) |
| 551 .WillOnce(Return(true)); | 551 .WillOnce(Return(true)); |
| 552 ASSERT_FALSE(TestUpdateCheck(&prefs, | 552 ASSERT_FALSE(TestUpdateCheck(&prefs, |
| 553 kDefaultTestParams, | 553 kDefaultTestParams, |
| 554 "invalid xml>", | 554 "invalid xml>", |
| 555 -1, | 555 -1, |
| 556 kActionCodeOmahaRequestXMLParseError, | 556 kActionCodeOmahaRequestXMLParseError, |
| 557 NULL, // response | 557 NULL, // response |
| 558 &post_data)); | 558 &post_data)); |
| 559 // convert post_data to string | 559 // convert post_data to string |
| 560 string post_str(&post_data[0], post_data.size()); | 560 string post_str(&post_data[0], post_data.size()); |
| 561 EXPECT_NE(post_str.find(" <o:ping a=\"-1\" r=\"-1\"></o:ping>\n" | 561 EXPECT_NE(post_str.find(" <o:ping a=\"-1\" r=\"-1\"></o:ping>\n" |
| 562 " <o:updatecheck></o:updatecheck>\n"), | 562 " <o:updatecheck></o:updatecheck>\n"), |
| 563 string::npos); | 563 string::npos); |
| 564 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), | 564 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), |
| 565 string::npos); | 565 string::npos); |
| 566 string prev_version_event = StringPrintf( | 566 string prev_version_event = StringPrintf( |
| 567 " <o:event eventtype=\"%d\" eventresult=\"%d\" " | 567 " <o:event eventtype=\"%d\" eventresult=\"%d\" " |
| 568 "previousversion=\"1.2.3.4\"></o:event>\n", | 568 "previousversion=\"1.2>3.4\"></o:event>\n", |
| 569 OmahaEvent::kTypeUpdateComplete, | 569 OmahaEvent::kTypeUpdateComplete, |
| 570 OmahaEvent::kResultSuccessReboot); | 570 OmahaEvent::kResultSuccessReboot); |
| 571 EXPECT_NE(post_str.find(prev_version_event), string::npos); | 571 EXPECT_NE(post_str.find(prev_version_event), string::npos); |
| 572 } | 572 } |
| 573 | 573 |
| 574 TEST(OmahaRequestActionTest, FormatSuccessEventOutputTest) { | 574 TEST(OmahaRequestActionTest, FormatSuccessEventOutputTest) { |
| 575 vector<char> post_data; | 575 vector<char> post_data; |
| 576 TestEvent(kDefaultTestParams, | 576 TestEvent(kDefaultTestParams, |
| 577 new OmahaEvent(OmahaEvent::kTypeUpdateDownloadStarted), | 577 new OmahaEvent(OmahaEvent::kTypeUpdateDownloadStarted), |
| 578 "invalid xml>", | 578 "invalid xml>", |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 "", | 903 "", |
| 904 1500, | 904 1500, |
| 905 static_cast<ActionExitCode>( | 905 static_cast<ActionExitCode>( |
| 906 kActionCodeOmahaRequestHTTPResponseBase + 999), | 906 kActionCodeOmahaRequestHTTPResponseBase + 999), |
| 907 &response, | 907 &response, |
| 908 NULL)); | 908 NULL)); |
| 909 EXPECT_FALSE(response.update_exists); | 909 EXPECT_FALSE(response.update_exists); |
| 910 } | 910 } |
| 911 | 911 |
| 912 } // namespace chromeos_update_engine | 912 } // namespace chromeos_update_engine |
| OLD | NEW |