| 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 kActionCodeError), | 596 kActionCodeError), |
| 597 "invalid xml>", | 597 "invalid xml>", |
| 598 &post_data); | 598 &post_data); |
| 599 // convert post_data to string | 599 // convert post_data to string |
| 600 string post_str(&post_data[0], post_data.size()); | 600 string post_str(&post_data[0], post_data.size()); |
| 601 string expected_event = StringPrintf( | 601 string expected_event = StringPrintf( |
| 602 " <o:event eventtype=\"%d\" eventresult=\"%d\" " | 602 " <o:event eventtype=\"%d\" eventresult=\"%d\" " |
| 603 "errorcode=\"%d\"></o:event>\n", | 603 "errorcode=\"%d\"></o:event>\n", |
| 604 OmahaEvent::kTypeDownloadComplete, | 604 OmahaEvent::kTypeDownloadComplete, |
| 605 OmahaEvent::kResultError, | 605 OmahaEvent::kResultError, |
| 606 kActionCodeError); | 606 kActionCodeError | kActionCodeBootModeFlag); |
| 607 EXPECT_NE(post_str.find(expected_event), string::npos); | 607 EXPECT_NE(post_str.find(expected_event), string::npos); |
| 608 EXPECT_EQ(post_str.find("o:updatecheck"), string::npos); | 608 EXPECT_EQ(post_str.find("o:updatecheck"), string::npos); |
| 609 } | 609 } |
| 610 | |
| 611 TEST(OmahaRequestActionTest, FormatEventOutputTest) { | |
| 612 vector<char> post_data; | |
| 613 TestEvent(kDefaultTestParams, | |
| 614 new OmahaEvent(OmahaEvent::kTypeDownloadComplete, | |
| 615 OmahaEvent::kResultError, | |
| 616 kActionCodeError), | |
| 617 "invalid xml>", | |
| 618 &post_data); | |
| 619 // convert post_data to string | |
| 620 string post_str(&post_data[0], post_data.size()); | |
| 621 string expected_event = StringPrintf( | |
| 622 " <o:event eventtype=\"%d\" eventresult=\"%d\" " | |
| 623 "errorcode=\"%d\"></o:event>\n", | |
| 624 OmahaEvent::kTypeDownloadComplete, | |
| 625 OmahaEvent::kResultError, | |
| 626 kActionCodeError); | |
| 627 EXPECT_NE(post_str.find(expected_event), string::npos); | |
| 628 EXPECT_EQ(post_str.find("o:updatecheck"), string::npos); | |
| 629 } | |
| 630 | 610 |
| 631 TEST(OmahaRequestActionTest, IsEventTest) { | 611 TEST(OmahaRequestActionTest, IsEventTest) { |
| 632 string http_response("doesn't matter"); | 612 string http_response("doesn't matter"); |
| 633 NiceMock<PrefsMock> prefs; | 613 NiceMock<PrefsMock> prefs; |
| 634 OmahaRequestAction update_check_action( | 614 OmahaRequestAction update_check_action( |
| 635 &prefs, | 615 &prefs, |
| 636 kDefaultTestParams, | 616 kDefaultTestParams, |
| 637 NULL, | 617 NULL, |
| 638 new MockHttpFetcher(http_response.data(), | 618 new MockHttpFetcher(http_response.data(), |
| 639 http_response.size(), | 619 http_response.size(), |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 "", | 903 "", |
| 924 1500, | 904 1500, |
| 925 static_cast<ActionExitCode>( | 905 static_cast<ActionExitCode>( |
| 926 kActionCodeOmahaRequestHTTPResponseBase + 999), | 906 kActionCodeOmahaRequestHTTPResponseBase + 999), |
| 927 &response, | 907 &response, |
| 928 NULL)); | 908 NULL)); |
| 929 EXPECT_FALSE(response.update_exists); | 909 EXPECT_FALSE(response.update_exists); |
| 930 } | 910 } |
| 931 | 911 |
| 932 } // namespace chromeos_update_engine | 912 } // namespace chromeos_update_engine |
| OLD | NEW |