| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), | 162 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), |
| 163 http_response.size(), | 163 http_response.size(), |
| 164 NULL); | 164 NULL); |
| 165 if (fail_http_response_code >= 0) { | 165 if (fail_http_response_code >= 0) { |
| 166 fetcher->FailTransfer(fail_http_response_code); | 166 fetcher->FailTransfer(fail_http_response_code); |
| 167 } | 167 } |
| 168 NiceMock<PrefsMock> local_prefs; | 168 NiceMock<PrefsMock> local_prefs; |
| 169 OmahaRequestAction action(prefs ? prefs : &local_prefs, | 169 OmahaRequestAction action(prefs ? prefs : &local_prefs, |
| 170 params, | 170 params, |
| 171 NULL, | 171 NULL, |
| 172 fetcher); | 172 fetcher, |
| 173 false); |
| 173 OmahaRequestActionTestProcessorDelegate delegate; | 174 OmahaRequestActionTestProcessorDelegate delegate; |
| 174 delegate.loop_ = loop; | 175 delegate.loop_ = loop; |
| 175 delegate.expected_code_ = expected_code; | 176 delegate.expected_code_ = expected_code; |
| 176 | 177 |
| 177 ActionProcessor processor; | 178 ActionProcessor processor; |
| 178 processor.set_delegate(&delegate); | 179 processor.set_delegate(&delegate); |
| 179 processor.EnqueueAction(&action); | 180 processor.EnqueueAction(&action); |
| 180 | 181 |
| 181 OutputObjectCollectorAction collector_action; | 182 OutputObjectCollectorAction collector_action; |
| 182 BondActions(&action, &collector_action); | 183 BondActions(&action, &collector_action); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 197 // HttpFetcher is returned. | 198 // HttpFetcher is returned. |
| 198 void TestEvent(const OmahaRequestParams& params, | 199 void TestEvent(const OmahaRequestParams& params, |
| 199 OmahaEvent* event, | 200 OmahaEvent* event, |
| 200 const string& http_response, | 201 const string& http_response, |
| 201 vector<char>* out_post_data) { | 202 vector<char>* out_post_data) { |
| 202 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); | 203 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); |
| 203 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), | 204 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), |
| 204 http_response.size(), | 205 http_response.size(), |
| 205 NULL); | 206 NULL); |
| 206 NiceMock<PrefsMock> prefs; | 207 NiceMock<PrefsMock> prefs; |
| 207 OmahaRequestAction action(&prefs, params, event, fetcher); | 208 OmahaRequestAction action(&prefs, params, event, fetcher, false); |
| 208 OmahaRequestActionTestProcessorDelegate delegate; | 209 OmahaRequestActionTestProcessorDelegate delegate; |
| 209 delegate.loop_ = loop; | 210 delegate.loop_ = loop; |
| 210 ActionProcessor processor; | 211 ActionProcessor processor; |
| 211 processor.set_delegate(&delegate); | 212 processor.set_delegate(&delegate); |
| 212 processor.EnqueueAction(&action); | 213 processor.EnqueueAction(&action); |
| 213 | 214 |
| 214 g_timeout_add(0, &StartProcessorInRunLoop, &processor); | 215 g_timeout_add(0, &StartProcessorInRunLoop, &processor); |
| 215 g_main_loop_run(loop); | 216 g_main_loop_run(loop); |
| 216 g_main_loop_unref(loop); | 217 g_main_loop_unref(loop); |
| 217 if (out_post_data) | 218 if (out_post_data) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 264 |
| 264 TEST(OmahaRequestActionTest, NoOutputPipeTest) { | 265 TEST(OmahaRequestActionTest, NoOutputPipeTest) { |
| 265 const string http_response(GetNoUpdateResponse(OmahaRequestParams::kAppId)); | 266 const string http_response(GetNoUpdateResponse(OmahaRequestParams::kAppId)); |
| 266 | 267 |
| 267 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); | 268 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); |
| 268 | 269 |
| 269 NiceMock<PrefsMock> prefs; | 270 NiceMock<PrefsMock> prefs; |
| 270 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL, | 271 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL, |
| 271 new MockHttpFetcher(http_response.data(), | 272 new MockHttpFetcher(http_response.data(), |
| 272 http_response.size(), | 273 http_response.size(), |
| 273 NULL)); | 274 NULL), |
| 275 false); |
| 274 OmahaRequestActionTestProcessorDelegate delegate; | 276 OmahaRequestActionTestProcessorDelegate delegate; |
| 275 delegate.loop_ = loop; | 277 delegate.loop_ = loop; |
| 276 ActionProcessor processor; | 278 ActionProcessor processor; |
| 277 processor.set_delegate(&delegate); | 279 processor.set_delegate(&delegate); |
| 278 processor.EnqueueAction(&action); | 280 processor.EnqueueAction(&action); |
| 279 | 281 |
| 280 g_timeout_add(0, &StartProcessorInRunLoop, &processor); | 282 g_timeout_add(0, &StartProcessorInRunLoop, &processor); |
| 281 g_main_loop_run(loop); | 283 g_main_loop_run(loop); |
| 282 g_main_loop_unref(loop); | 284 g_main_loop_unref(loop); |
| 283 EXPECT_FALSE(processor.IsRunning()); | 285 EXPECT_FALSE(processor.IsRunning()); |
| 284 } | 286 } |
| 285 | 287 |
| 286 TEST(OmahaRequestActionTest, SkipTest) { | 288 TEST(OmahaRequestActionTest, SkipTest) { |
| 287 const string http_response("invalid xml>"); | 289 const string http_response("invalid xml>"); |
| 288 | 290 |
| 289 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); | 291 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); |
| 290 | 292 |
| 291 NiceMock<PrefsMock> prefs; | 293 NiceMock<PrefsMock> prefs; |
| 292 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), | 294 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), |
| 293 http_response.size(), | 295 http_response.size(), |
| 294 NULL); | 296 NULL); |
| 295 fetcher->set_never_use(true); | 297 fetcher->set_never_use(true); |
| 296 OmahaRequestAction action(&prefs, kDefaultTestParams, | 298 OmahaRequestAction action(&prefs, kDefaultTestParams, |
| 297 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), | 299 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
| 298 fetcher); // Passes fetcher ownership | 300 fetcher, // Passes fetcher ownership |
| 301 false); |
| 299 action.set_should_skip(true); | 302 action.set_should_skip(true); |
| 300 OmahaRequestActionTestProcessorDelegate delegate; | 303 OmahaRequestActionTestProcessorDelegate delegate; |
| 301 delegate.loop_ = loop; | 304 delegate.loop_ = loop; |
| 302 ActionProcessor processor; | 305 ActionProcessor processor; |
| 303 processor.set_delegate(&delegate); | 306 processor.set_delegate(&delegate); |
| 304 processor.EnqueueAction(&action); | 307 processor.EnqueueAction(&action); |
| 305 | 308 |
| 306 g_timeout_add(0, &StartProcessorInRunLoop, &processor); | 309 g_timeout_add(0, &StartProcessorInRunLoop, &processor); |
| 307 g_main_loop_run(loop); | 310 g_main_loop_run(loop); |
| 308 g_main_loop_unref(loop); | 311 g_main_loop_unref(loop); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } // namespace {} | 440 } // namespace {} |
| 438 | 441 |
| 439 TEST(OmahaRequestActionTest, TerminateTransferTest) { | 442 TEST(OmahaRequestActionTest, TerminateTransferTest) { |
| 440 string http_response("doesn't matter"); | 443 string http_response("doesn't matter"); |
| 441 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); | 444 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); |
| 442 | 445 |
| 443 NiceMock<PrefsMock> prefs; | 446 NiceMock<PrefsMock> prefs; |
| 444 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL, | 447 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL, |
| 445 new MockHttpFetcher(http_response.data(), | 448 new MockHttpFetcher(http_response.data(), |
| 446 http_response.size(), | 449 http_response.size(), |
| 447 NULL)); | 450 NULL), |
| 451 false); |
| 448 TerminateEarlyTestProcessorDelegate delegate; | 452 TerminateEarlyTestProcessorDelegate delegate; |
| 449 delegate.loop_ = loop; | 453 delegate.loop_ = loop; |
| 450 ActionProcessor processor; | 454 ActionProcessor processor; |
| 451 processor.set_delegate(&delegate); | 455 processor.set_delegate(&delegate); |
| 452 processor.EnqueueAction(&action); | 456 processor.EnqueueAction(&action); |
| 453 | 457 |
| 454 g_timeout_add(0, &TerminateTransferTestStarter, &processor); | 458 g_timeout_add(0, &TerminateTransferTestStarter, &processor); |
| 455 g_main_loop_run(loop); | 459 g_main_loop_run(loop); |
| 456 g_main_loop_unref(loop); | 460 g_main_loop_unref(loop); |
| 457 } | 461 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, _)).Times(0); | 557 EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, _)).Times(0); |
| 554 ASSERT_FALSE(TestUpdateCheck(&prefs, | 558 ASSERT_FALSE(TestUpdateCheck(&prefs, |
| 555 kDefaultTestParams, | 559 kDefaultTestParams, |
| 556 "invalid xml>", | 560 "invalid xml>", |
| 557 -1, | 561 -1, |
| 558 kActionCodeOmahaRequestXMLParseError, | 562 kActionCodeOmahaRequestXMLParseError, |
| 559 NULL, // response | 563 NULL, // response |
| 560 &post_data)); | 564 &post_data)); |
| 561 // convert post_data to string | 565 // convert post_data to string |
| 562 string post_str(&post_data[0], post_data.size()); | 566 string post_str(&post_data[0], post_data.size()); |
| 563 EXPECT_NE(post_str.find(" <o:ping a=\"-1\" r=\"-1\"></o:ping>\n" | 567 EXPECT_NE(post_str.find( |
| 564 " <o:updatecheck></o:updatecheck>\n"), | 568 " <o:ping active=\"1\" a=\"-1\" r=\"-1\"></o:ping>\n" |
| 569 " <o:updatecheck></o:updatecheck>\n"), |
| 565 string::npos); | 570 string::npos); |
| 566 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), | 571 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), |
| 567 string::npos); | 572 string::npos); |
| 568 EXPECT_EQ(post_str.find("o:event"), string::npos); | 573 EXPECT_EQ(post_str.find("o:event"), string::npos); |
| 569 } | 574 } |
| 570 | 575 |
| 571 TEST(OmahaRequestActionTest, FormatUpdateCheckPrevVersionOutputTest) { | 576 TEST(OmahaRequestActionTest, FormatUpdateCheckPrevVersionOutputTest) { |
| 572 vector<char> post_data; | 577 vector<char> post_data; |
| 573 NiceMock<PrefsMock> prefs; | 578 NiceMock<PrefsMock> prefs; |
| 574 EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _)) | 579 EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _)) |
| 575 .WillOnce(DoAll(SetArgumentPointee<1>(string("1.2>3.4")), Return(true))); | 580 .WillOnce(DoAll(SetArgumentPointee<1>(string("1.2>3.4")), Return(true))); |
| 576 EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, "")) | 581 EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, "")) |
| 577 .WillOnce(Return(true)); | 582 .WillOnce(Return(true)); |
| 578 ASSERT_FALSE(TestUpdateCheck(&prefs, | 583 ASSERT_FALSE(TestUpdateCheck(&prefs, |
| 579 kDefaultTestParams, | 584 kDefaultTestParams, |
| 580 "invalid xml>", | 585 "invalid xml>", |
| 581 -1, | 586 -1, |
| 582 kActionCodeOmahaRequestXMLParseError, | 587 kActionCodeOmahaRequestXMLParseError, |
| 583 NULL, // response | 588 NULL, // response |
| 584 &post_data)); | 589 &post_data)); |
| 585 // convert post_data to string | 590 // convert post_data to string |
| 586 string post_str(&post_data[0], post_data.size()); | 591 string post_str(&post_data[0], post_data.size()); |
| 587 EXPECT_NE(post_str.find(" <o:ping a=\"-1\" r=\"-1\"></o:ping>\n" | 592 EXPECT_NE(post_str.find( |
| 588 " <o:updatecheck></o:updatecheck>\n"), | 593 " <o:ping active=\"1\" a=\"-1\" r=\"-1\"></o:ping>\n" |
| 594 " <o:updatecheck></o:updatecheck>\n"), |
| 589 string::npos); | 595 string::npos); |
| 590 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), | 596 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""), |
| 591 string::npos); | 597 string::npos); |
| 592 string prev_version_event = StringPrintf( | 598 string prev_version_event = StringPrintf( |
| 593 " <o:event eventtype=\"%d\" eventresult=\"%d\" " | 599 " <o:event eventtype=\"%d\" eventresult=\"%d\" " |
| 594 "previousversion=\"1.2>3.4\"></o:event>\n", | 600 "previousversion=\"1.2>3.4\"></o:event>\n", |
| 595 OmahaEvent::kTypeUpdateComplete, | 601 OmahaEvent::kTypeUpdateComplete, |
| 596 OmahaEvent::kResultSuccessReboot); | 602 OmahaEvent::kResultSuccessReboot); |
| 597 EXPECT_NE(post_str.find(prev_version_event), string::npos); | 603 EXPECT_NE(post_str.find(prev_version_event), string::npos); |
| 598 } | 604 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 642 |
| 637 TEST(OmahaRequestActionTest, IsEventTest) { | 643 TEST(OmahaRequestActionTest, IsEventTest) { |
| 638 string http_response("doesn't matter"); | 644 string http_response("doesn't matter"); |
| 639 NiceMock<PrefsMock> prefs; | 645 NiceMock<PrefsMock> prefs; |
| 640 OmahaRequestAction update_check_action( | 646 OmahaRequestAction update_check_action( |
| 641 &prefs, | 647 &prefs, |
| 642 kDefaultTestParams, | 648 kDefaultTestParams, |
| 643 NULL, | 649 NULL, |
| 644 new MockHttpFetcher(http_response.data(), | 650 new MockHttpFetcher(http_response.data(), |
| 645 http_response.size(), | 651 http_response.size(), |
| 646 NULL)); | 652 NULL), |
| 653 false); |
| 647 EXPECT_FALSE(update_check_action.IsEvent()); | 654 EXPECT_FALSE(update_check_action.IsEvent()); |
| 648 | 655 |
| 649 OmahaRequestAction event_action( | 656 OmahaRequestAction event_action( |
| 650 &prefs, | 657 &prefs, |
| 651 kDefaultTestParams, | 658 kDefaultTestParams, |
| 652 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), | 659 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
| 653 new MockHttpFetcher(http_response.data(), | 660 new MockHttpFetcher(http_response.data(), |
| 654 http_response.size(), | 661 http_response.size(), |
| 655 NULL)); | 662 NULL), |
| 663 false); |
| 656 EXPECT_TRUE(event_action.IsEvent()); | 664 EXPECT_TRUE(event_action.IsEvent()); |
| 657 } | 665 } |
| 658 | 666 |
| 659 TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) { | 667 TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) { |
| 660 for (int i = 0; i < 2; i++) { | 668 for (int i = 0; i < 2; i++) { |
| 661 bool delta_okay = i == 1; | 669 bool delta_okay = i == 1; |
| 662 const char* delta_okay_str = delta_okay ? "true" : "false"; | 670 const char* delta_okay_str = delta_okay ? "true" : "false"; |
| 663 vector<char> post_data; | 671 vector<char> post_data; |
| 664 OmahaRequestParams params(OmahaRequestParams::kOsPlatform, | 672 OmahaRequestParams params(OmahaRequestParams::kOsPlatform, |
| 665 OmahaRequestParams::kOsVersion, | 673 OmahaRequestParams::kOsVersion, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 vector<char> post_data; | 728 vector<char> post_data; |
| 721 ASSERT_TRUE( | 729 ASSERT_TRUE( |
| 722 TestUpdateCheck(&prefs, | 730 TestUpdateCheck(&prefs, |
| 723 kDefaultTestParams, | 731 kDefaultTestParams, |
| 724 GetNoUpdateResponse(OmahaRequestParams::kAppId), | 732 GetNoUpdateResponse(OmahaRequestParams::kAppId), |
| 725 -1, | 733 -1, |
| 726 kActionCodeSuccess, | 734 kActionCodeSuccess, |
| 727 NULL, | 735 NULL, |
| 728 &post_data)); | 736 &post_data)); |
| 729 string post_str(&post_data[0], post_data.size()); | 737 string post_str(&post_data[0], post_data.size()); |
| 730 EXPECT_NE(post_str.find("<o:ping a=\"6\" r=\"5\"></o:ping>"), string::npos); | 738 EXPECT_NE(post_str.find("<o:ping active=\"1\" a=\"6\" r=\"5\"></o:ping>"), |
| 739 string::npos); |
| 731 } | 740 } |
| 732 | 741 |
| 733 TEST(OmahaRequestActionTest, ActivePingTest) { | 742 TEST(OmahaRequestActionTest, ActivePingTest) { |
| 734 NiceMock<PrefsMock> prefs; | 743 NiceMock<PrefsMock> prefs; |
| 735 int64_t three_days_ago = | 744 int64_t three_days_ago = |
| 736 (Time::Now() - TimeDelta::FromHours(3 * 24 + 12)).ToInternalValue(); | 745 (Time::Now() - TimeDelta::FromHours(3 * 24 + 12)).ToInternalValue(); |
| 737 int64_t now = Time::Now().ToInternalValue(); | 746 int64_t now = Time::Now().ToInternalValue(); |
| 738 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _)) | 747 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _)) |
| 739 .WillOnce(DoAll(SetArgumentPointee<1>(three_days_ago), Return(true))); | 748 .WillOnce(DoAll(SetArgumentPointee<1>(three_days_ago), Return(true))); |
| 740 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _)) | 749 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _)) |
| 741 .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true))); | 750 .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true))); |
| 742 vector<char> post_data; | 751 vector<char> post_data; |
| 743 ASSERT_TRUE( | 752 ASSERT_TRUE( |
| 744 TestUpdateCheck(&prefs, | 753 TestUpdateCheck(&prefs, |
| 745 kDefaultTestParams, | 754 kDefaultTestParams, |
| 746 GetNoUpdateResponse(OmahaRequestParams::kAppId), | 755 GetNoUpdateResponse(OmahaRequestParams::kAppId), |
| 747 -1, | 756 -1, |
| 748 kActionCodeSuccess, | 757 kActionCodeSuccess, |
| 749 NULL, | 758 NULL, |
| 750 &post_data)); | 759 &post_data)); |
| 751 string post_str(&post_data[0], post_data.size()); | 760 string post_str(&post_data[0], post_data.size()); |
| 752 EXPECT_NE(post_str.find("<o:ping a=\"3\"></o:ping>"), string::npos); | 761 EXPECT_NE(post_str.find("<o:ping active=\"1\" a=\"3\"></o:ping>"), |
| 762 string::npos); |
| 753 } | 763 } |
| 754 | 764 |
| 755 TEST(OmahaRequestActionTest, RollCallPingTest) { | 765 TEST(OmahaRequestActionTest, RollCallPingTest) { |
| 756 NiceMock<PrefsMock> prefs; | 766 NiceMock<PrefsMock> prefs; |
| 757 int64_t four_days_ago = | 767 int64_t four_days_ago = |
| 758 (Time::Now() - TimeDelta::FromHours(4 * 24)).ToInternalValue(); | 768 (Time::Now() - TimeDelta::FromHours(4 * 24)).ToInternalValue(); |
| 759 int64_t now = Time::Now().ToInternalValue(); | 769 int64_t now = Time::Now().ToInternalValue(); |
| 760 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _)) | 770 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _)) |
| 761 .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true))); | 771 .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true))); |
| 762 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _)) | 772 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _)) |
| 763 .WillOnce(DoAll(SetArgumentPointee<1>(four_days_ago), Return(true))); | 773 .WillOnce(DoAll(SetArgumentPointee<1>(four_days_ago), Return(true))); |
| 764 vector<char> post_data; | 774 vector<char> post_data; |
| 765 ASSERT_TRUE( | 775 ASSERT_TRUE( |
| 766 TestUpdateCheck(&prefs, | 776 TestUpdateCheck(&prefs, |
| 767 kDefaultTestParams, | 777 kDefaultTestParams, |
| 768 GetNoUpdateResponse(OmahaRequestParams::kAppId), | 778 GetNoUpdateResponse(OmahaRequestParams::kAppId), |
| 769 -1, | 779 -1, |
| 770 kActionCodeSuccess, | 780 kActionCodeSuccess, |
| 771 NULL, | 781 NULL, |
| 772 &post_data)); | 782 &post_data)); |
| 773 string post_str(&post_data[0], post_data.size()); | 783 string post_str(&post_data[0], post_data.size()); |
| 774 EXPECT_NE(post_str.find("<o:ping r=\"4\"></o:ping>\n"), string::npos); | 784 EXPECT_NE(post_str.find("<o:ping active=\"1\" r=\"4\"></o:ping>\n"), |
| 785 string::npos); |
| 775 } | 786 } |
| 776 | 787 |
| 777 TEST(OmahaRequestActionTest, NoPingTest) { | 788 TEST(OmahaRequestActionTest, NoPingTest) { |
| 778 NiceMock<PrefsMock> prefs; | 789 NiceMock<PrefsMock> prefs; |
| 779 int64_t one_hour_ago = | 790 int64_t one_hour_ago = |
| 780 (Time::Now() - TimeDelta::FromHours(1)).ToInternalValue(); | 791 (Time::Now() - TimeDelta::FromHours(1)).ToInternalValue(); |
| 781 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _)) | 792 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _)) |
| 782 .WillOnce(DoAll(SetArgumentPointee<1>(one_hour_ago), Return(true))); | 793 .WillOnce(DoAll(SetArgumentPointee<1>(one_hour_ago), Return(true))); |
| 783 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _)) | 794 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _)) |
| 784 .WillOnce(DoAll(SetArgumentPointee<1>(one_hour_ago), Return(true))); | 795 .WillOnce(DoAll(SetArgumentPointee<1>(one_hour_ago), Return(true))); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 "", | 940 "", |
| 930 1500, | 941 1500, |
| 931 static_cast<ActionExitCode>( | 942 static_cast<ActionExitCode>( |
| 932 kActionCodeOmahaRequestHTTPResponseBase + 999), | 943 kActionCodeOmahaRequestHTTPResponseBase + 999), |
| 933 &response, | 944 &response, |
| 934 NULL)); | 945 NULL)); |
| 935 EXPECT_FALSE(response.update_exists); | 946 EXPECT_FALSE(response.update_exists); |
| 936 } | 947 } |
| 937 | 948 |
| 938 } // namespace chromeos_update_engine | 949 } // namespace chromeos_update_engine |
| OLD | NEW |