Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: omaha_request_action_unittest.cc

Issue 5205002: AU: Manual proxy support (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: missed one fix for review Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « multi_http_fetcher.h ('k') | proxy_resolver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // returned. 153 // returned.
154 bool TestUpdateCheck(PrefsInterface* prefs, 154 bool TestUpdateCheck(PrefsInterface* prefs,
155 const OmahaRequestParams& params, 155 const OmahaRequestParams& params,
156 const string& http_response, 156 const string& http_response,
157 int fail_http_response_code, 157 int fail_http_response_code,
158 ActionExitCode expected_code, 158 ActionExitCode expected_code,
159 OmahaResponse* out_response, 159 OmahaResponse* out_response,
160 vector<char>* out_post_data) { 160 vector<char>* out_post_data) {
161 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); 161 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
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 if (fail_http_response_code >= 0) { 165 if (fail_http_response_code >= 0) {
165 fetcher->FailTransfer(fail_http_response_code); 166 fetcher->FailTransfer(fail_http_response_code);
166 } 167 }
167 NiceMock<PrefsMock> local_prefs; 168 NiceMock<PrefsMock> local_prefs;
168 OmahaRequestAction action(prefs ? prefs : &local_prefs, 169 OmahaRequestAction action(prefs ? prefs : &local_prefs,
169 params, 170 params,
170 NULL, 171 NULL,
171 fetcher); 172 fetcher);
172 OmahaRequestActionTestProcessorDelegate delegate; 173 OmahaRequestActionTestProcessorDelegate delegate;
173 delegate.loop_ = loop; 174 delegate.loop_ = loop;
(...skipping 19 matching lines...) Expand all
193 194
194 // Tests Event requests -- they should always succeed. |out_post_data| 195 // Tests Event requests -- they should always succeed. |out_post_data|
195 // may be null; if non-null, the post-data received by the mock 196 // may be null; if non-null, the post-data received by the mock
196 // HttpFetcher is returned. 197 // HttpFetcher is returned.
197 void TestEvent(const OmahaRequestParams& params, 198 void TestEvent(const OmahaRequestParams& params,
198 OmahaEvent* event, 199 OmahaEvent* event,
199 const string& http_response, 200 const string& http_response,
200 vector<char>* out_post_data) { 201 vector<char>* out_post_data) {
201 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); 202 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
202 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), 203 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(),
203 http_response.size()); 204 http_response.size(),
205 NULL);
204 NiceMock<PrefsMock> prefs; 206 NiceMock<PrefsMock> prefs;
205 OmahaRequestAction action(&prefs, params, event, fetcher); 207 OmahaRequestAction action(&prefs, params, event, fetcher);
206 OmahaRequestActionTestProcessorDelegate delegate; 208 OmahaRequestActionTestProcessorDelegate delegate;
207 delegate.loop_ = loop; 209 delegate.loop_ = loop;
208 ActionProcessor processor; 210 ActionProcessor processor;
209 processor.set_delegate(&delegate); 211 processor.set_delegate(&delegate);
210 processor.EnqueueAction(&action); 212 processor.EnqueueAction(&action);
211 213
212 g_timeout_add(0, &StartProcessorInRunLoop, &processor); 214 g_timeout_add(0, &StartProcessorInRunLoop, &processor);
213 g_main_loop_run(loop); 215 g_main_loop_run(loop);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 262 }
261 263
262 TEST(OmahaRequestActionTest, NoOutputPipeTest) { 264 TEST(OmahaRequestActionTest, NoOutputPipeTest) {
263 const string http_response(GetNoUpdateResponse(OmahaRequestParams::kAppId)); 265 const string http_response(GetNoUpdateResponse(OmahaRequestParams::kAppId));
264 266
265 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); 267 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
266 268
267 NiceMock<PrefsMock> prefs; 269 NiceMock<PrefsMock> prefs;
268 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL, 270 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL,
269 new MockHttpFetcher(http_response.data(), 271 new MockHttpFetcher(http_response.data(),
270 http_response.size())); 272 http_response.size(),
273 NULL));
271 OmahaRequestActionTestProcessorDelegate delegate; 274 OmahaRequestActionTestProcessorDelegate delegate;
272 delegate.loop_ = loop; 275 delegate.loop_ = loop;
273 ActionProcessor processor; 276 ActionProcessor processor;
274 processor.set_delegate(&delegate); 277 processor.set_delegate(&delegate);
275 processor.EnqueueAction(&action); 278 processor.EnqueueAction(&action);
276 279
277 g_timeout_add(0, &StartProcessorInRunLoop, &processor); 280 g_timeout_add(0, &StartProcessorInRunLoop, &processor);
278 g_main_loop_run(loop); 281 g_main_loop_run(loop);
279 g_main_loop_unref(loop); 282 g_main_loop_unref(loop);
280 EXPECT_FALSE(processor.IsRunning()); 283 EXPECT_FALSE(processor.IsRunning());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 410 }
408 } // namespace {} 411 } // namespace {}
409 412
410 TEST(OmahaRequestActionTest, TerminateTransferTest) { 413 TEST(OmahaRequestActionTest, TerminateTransferTest) {
411 string http_response("doesn't matter"); 414 string http_response("doesn't matter");
412 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); 415 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
413 416
414 NiceMock<PrefsMock> prefs; 417 NiceMock<PrefsMock> prefs;
415 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL, 418 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL,
416 new MockHttpFetcher(http_response.data(), 419 new MockHttpFetcher(http_response.data(),
417 http_response.size())); 420 http_response.size(),
421 NULL));
418 TerminateEarlyTestProcessorDelegate delegate; 422 TerminateEarlyTestProcessorDelegate delegate;
419 delegate.loop_ = loop; 423 delegate.loop_ = loop;
420 ActionProcessor processor; 424 ActionProcessor processor;
421 processor.set_delegate(&delegate); 425 processor.set_delegate(&delegate);
422 processor.EnqueueAction(&action); 426 processor.EnqueueAction(&action);
423 427
424 g_timeout_add(0, &TerminateTransferTestStarter, &processor); 428 g_timeout_add(0, &TerminateTransferTestStarter, &processor);
425 g_main_loop_run(loop); 429 g_main_loop_run(loop);
426 g_main_loop_unref(loop); 430 g_main_loop_unref(loop);
427 } 431 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 } 596 }
593 597
594 TEST(OmahaRequestActionTest, IsEventTest) { 598 TEST(OmahaRequestActionTest, IsEventTest) {
595 string http_response("doesn't matter"); 599 string http_response("doesn't matter");
596 NiceMock<PrefsMock> prefs; 600 NiceMock<PrefsMock> prefs;
597 OmahaRequestAction update_check_action( 601 OmahaRequestAction update_check_action(
598 &prefs, 602 &prefs,
599 kDefaultTestParams, 603 kDefaultTestParams,
600 NULL, 604 NULL,
601 new MockHttpFetcher(http_response.data(), 605 new MockHttpFetcher(http_response.data(),
602 http_response.size())); 606 http_response.size(),
607 NULL));
603 EXPECT_FALSE(update_check_action.IsEvent()); 608 EXPECT_FALSE(update_check_action.IsEvent());
604 609
605 OmahaRequestAction event_action( 610 OmahaRequestAction event_action(
606 &prefs, 611 &prefs,
607 kDefaultTestParams, 612 kDefaultTestParams,
608 new OmahaEvent(OmahaEvent::kTypeUpdateComplete), 613 new OmahaEvent(OmahaEvent::kTypeUpdateComplete),
609 new MockHttpFetcher(http_response.data(), 614 new MockHttpFetcher(http_response.data(),
610 http_response.size())); 615 http_response.size(),
616 NULL));
611 EXPECT_TRUE(event_action.IsEvent()); 617 EXPECT_TRUE(event_action.IsEvent());
612 } 618 }
613 619
614 TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) { 620 TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) {
615 for (int i = 0; i < 2; i++) { 621 for (int i = 0; i < 2; i++) {
616 bool delta_okay = i == 1; 622 bool delta_okay = i == 1;
617 const char* delta_okay_str = delta_okay ? "true" : "false"; 623 const char* delta_okay_str = delta_okay ? "true" : "false";
618 vector<char> post_data; 624 vector<char> post_data;
619 OmahaRequestParams params(OmahaRequestParams::kOsPlatform, 625 OmahaRequestParams params(OmahaRequestParams::kOsPlatform,
620 OmahaRequestParams::kOsVersion, 626 OmahaRequestParams::kOsVersion,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 "", 890 "",
885 1500, 891 1500,
886 static_cast<ActionExitCode>( 892 static_cast<ActionExitCode>(
887 kActionCodeOmahaRequestHTTPResponseBase + 999), 893 kActionCodeOmahaRequestHTTPResponseBase + 999),
888 &response, 894 &response,
889 NULL)); 895 NULL));
890 EXPECT_FALSE(response.update_exists); 896 EXPECT_FALSE(response.update_exists);
891 } 897 }
892 898
893 } // namespace chromeos_update_engine 899 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « multi_http_fetcher.h ('k') | proxy_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698