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

Side by Side Diff: omaha_request_action_unittest.cc

Issue 3017006: AU: pass whether or not we can tolerate a delta to the server (Closed) Base URL: ssh://git@chromiumos-git/update_engine.git
Patch Set: merge master (which has petkov's CL in) Created 10 years, 5 months 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
« no previous file with comments | « omaha_request_action.cc ('k') | omaha_request_params.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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 OmahaRequestParams params("", // machine_id 182 OmahaRequestParams params("", // machine_id
183 "", // user_id 183 "", // user_id
184 OmahaRequestParams::kOsPlatform, 184 OmahaRequestParams::kOsPlatform,
185 OmahaRequestParams::kOsVersion, 185 OmahaRequestParams::kOsVersion,
186 "", // os_sp 186 "", // os_sp
187 "x86-generic", 187 "x86-generic",
188 OmahaRequestParams::kAppId, 188 OmahaRequestParams::kAppId,
189 "0.1.0.0", 189 "0.1.0.0",
190 "en-US", 190 "en-US",
191 "unittest", 191 "unittest",
192 false, // delta okay
192 ""); // url 193 ""); // url
193 OmahaResponse response; 194 OmahaResponse response;
194 ASSERT_TRUE( 195 ASSERT_TRUE(
195 TestUpdateCheck(params, 196 TestUpdateCheck(params,
196 GetNoUpdateResponse(OmahaRequestParams::kAppId), 197 GetNoUpdateResponse(OmahaRequestParams::kAppId),
197 true, 198 true,
198 &response, 199 &response,
199 NULL)); 200 NULL));
200 EXPECT_FALSE(response.update_exists); 201 EXPECT_FALSE(response.update_exists);
201 } 202 }
202 203
203 TEST(OmahaRequestActionTest, ValidUpdateTest) { 204 TEST(OmahaRequestActionTest, ValidUpdateTest) {
204 OmahaRequestParams params("machine_id", 205 OmahaRequestParams params("machine_id",
205 "user_id", 206 "user_id",
206 OmahaRequestParams::kOsPlatform, 207 OmahaRequestParams::kOsPlatform,
207 OmahaRequestParams::kOsVersion, 208 OmahaRequestParams::kOsVersion,
208 "service_pack", 209 "service_pack",
209 "arm-generic", 210 "arm-generic",
210 OmahaRequestParams::kAppId, 211 OmahaRequestParams::kAppId,
211 "0.1.0.0", 212 "0.1.0.0",
212 "en-US", 213 "en-US",
213 "unittest_track", 214 "unittest_track",
215 false, // delta okay
214 ""); // url 216 ""); // url
215 OmahaResponse response; 217 OmahaResponse response;
216 ASSERT_TRUE( 218 ASSERT_TRUE(
217 TestUpdateCheck(params, 219 TestUpdateCheck(params,
218 GetUpdateResponse(OmahaRequestParams::kAppId, 220 GetUpdateResponse(OmahaRequestParams::kAppId,
219 "1.2.3.4", // version 221 "1.2.3.4", // version
220 "http://more/info", 222 "http://more/info",
221 "true", // prompt 223 "true", // prompt
222 "http://code/base", // dl url 224 "http://code/base", // dl url
223 "HASH1234=", // checksum 225 "HASH1234=", // checksum
(...skipping 17 matching lines...) Expand all
241 OmahaRequestParams params("", // machine_id 243 OmahaRequestParams params("", // machine_id
242 "", // usr_id 244 "", // usr_id
243 OmahaRequestParams::kOsPlatform, 245 OmahaRequestParams::kOsPlatform,
244 OmahaRequestParams::kOsVersion, 246 OmahaRequestParams::kOsVersion,
245 "", // os_sp 247 "", // os_sp
246 "", // os_board 248 "", // os_board
247 OmahaRequestParams::kAppId, 249 OmahaRequestParams::kAppId,
248 "0.1.0.0", 250 "0.1.0.0",
249 "en-US", 251 "en-US",
250 "unittest", 252 "unittest",
253 false, // delta okay
251 ""); // url 254 ""); // url
252 const string http_response(GetNoUpdateResponse(OmahaRequestParams::kAppId)); 255 const string http_response(GetNoUpdateResponse(OmahaRequestParams::kAppId));
253 256
254 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); 257 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
255 258
256 OmahaRequestAction action(params, NULL, 259 OmahaRequestAction action(params, NULL,
257 new MockHttpFetcher(http_response.data(), 260 new MockHttpFetcher(http_response.data(),
258 http_response.size())); 261 http_response.size()));
259 OmahaRequestActionTestProcessorDelegate delegate; 262 OmahaRequestActionTestProcessorDelegate delegate;
260 delegate.loop_ = loop; 263 delegate.loop_ = loop;
(...skipping 11 matching lines...) Expand all
272 OmahaRequestParams params("machine_id", 275 OmahaRequestParams params("machine_id",
273 "user_id", 276 "user_id",
274 OmahaRequestParams::kOsPlatform, 277 OmahaRequestParams::kOsPlatform,
275 OmahaRequestParams::kOsVersion, 278 OmahaRequestParams::kOsVersion,
276 "service_pack", 279 "service_pack",
277 "x86-generic", 280 "x86-generic",
278 OmahaRequestParams::kAppId, 281 OmahaRequestParams::kAppId,
279 "0.1.0.0", 282 "0.1.0.0",
280 "en-US", 283 "en-US",
281 "unittest_track", 284 "unittest_track",
285 false, // delta okay
282 "http://url"); 286 "http://url");
283 OmahaResponse response; 287 OmahaResponse response;
284 ASSERT_FALSE( 288 ASSERT_FALSE(
285 TestUpdateCheck(params, 289 TestUpdateCheck(params,
286 "invalid xml>", 290 "invalid xml>",
287 false, 291 false,
288 &response, 292 &response,
289 NULL)); 293 NULL));
290 EXPECT_FALSE(response.update_exists); 294 EXPECT_FALSE(response.update_exists);
291 } 295 }
292 296
293 TEST(OmahaRequestActionTest, MissingStatusTest) { 297 TEST(OmahaRequestActionTest, MissingStatusTest) {
294 OmahaRequestParams params("machine_id", 298 OmahaRequestParams params("machine_id",
295 "user_id", 299 "user_id",
296 OmahaRequestParams::kOsPlatform, 300 OmahaRequestParams::kOsPlatform,
297 OmahaRequestParams::kOsVersion, 301 OmahaRequestParams::kOsVersion,
298 "service_pack", 302 "service_pack",
299 "x86-generic", 303 "x86-generic",
300 OmahaRequestParams::kAppId, 304 OmahaRequestParams::kAppId,
301 "0.1.0.0", 305 "0.1.0.0",
302 "en-US", 306 "en-US",
303 "unittest_track", 307 "unittest_track",
308 false, // delta okay
304 "http://url"); 309 "http://url");
305 OmahaResponse response; 310 OmahaResponse response;
306 ASSERT_FALSE(TestUpdateCheck( 311 ASSERT_FALSE(TestUpdateCheck(
307 params, 312 params,
308 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate " 313 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
309 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app " 314 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
310 "appid=\"foo\" status=\"ok\"><ping " 315 "appid=\"foo\" status=\"ok\"><ping "
311 "status=\"ok\"/><updatecheck/></app></gupdate>", 316 "status=\"ok\"/><updatecheck/></app></gupdate>",
312 false, 317 false,
313 &response, 318 &response,
314 NULL)); 319 NULL));
315 EXPECT_FALSE(response.update_exists); 320 EXPECT_FALSE(response.update_exists);
316 } 321 }
317 322
318 TEST(OmahaRequestActionTest, InvalidStatusTest) { 323 TEST(OmahaRequestActionTest, InvalidStatusTest) {
319 OmahaRequestParams params("machine_id", 324 OmahaRequestParams params("machine_id",
320 "user_id", 325 "user_id",
321 OmahaRequestParams::kOsPlatform, 326 OmahaRequestParams::kOsPlatform,
322 OmahaRequestParams::kOsVersion, 327 OmahaRequestParams::kOsVersion,
323 "service_pack", 328 "service_pack",
324 "x86-generic", 329 "x86-generic",
325 OmahaRequestParams::kAppId, 330 OmahaRequestParams::kAppId,
326 "0.1.0.0", 331 "0.1.0.0",
327 "en-US", 332 "en-US",
328 "unittest_track", 333 "unittest_track",
334 false, // delta okay
329 "http://url"); 335 "http://url");
330 OmahaResponse response; 336 OmahaResponse response;
331 ASSERT_FALSE(TestUpdateCheck( 337 ASSERT_FALSE(TestUpdateCheck(
332 params, 338 params,
333 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate " 339 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
334 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app " 340 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
335 "appid=\"foo\" status=\"ok\"><ping " 341 "appid=\"foo\" status=\"ok\"><ping "
336 "status=\"ok\"/><updatecheck status=\"foo\"/></app></gupdate>", 342 "status=\"ok\"/><updatecheck status=\"foo\"/></app></gupdate>",
337 false, 343 false,
338 &response, 344 &response,
339 NULL)); 345 NULL));
340 EXPECT_FALSE(response.update_exists); 346 EXPECT_FALSE(response.update_exists);
341 } 347 }
342 348
343 TEST(OmahaRequestActionTest, MissingNodesetTest) { 349 TEST(OmahaRequestActionTest, MissingNodesetTest) {
344 OmahaRequestParams params("machine_id", 350 OmahaRequestParams params("machine_id",
345 "user_id", 351 "user_id",
346 OmahaRequestParams::kOsPlatform, 352 OmahaRequestParams::kOsPlatform,
347 OmahaRequestParams::kOsVersion, 353 OmahaRequestParams::kOsVersion,
348 "service_pack", 354 "service_pack",
349 "x86-generic", 355 "x86-generic",
350 OmahaRequestParams::kAppId, 356 OmahaRequestParams::kAppId,
351 "0.1.0.0", 357 "0.1.0.0",
352 "en-US", 358 "en-US",
353 "unittest_track", 359 "unittest_track",
360 false, // delta okay
354 "http://url"); 361 "http://url");
355 OmahaResponse response; 362 OmahaResponse response;
356 ASSERT_FALSE(TestUpdateCheck( 363 ASSERT_FALSE(TestUpdateCheck(
357 params, 364 params,
358 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate " 365 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
359 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app " 366 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
360 "appid=\"foo\" status=\"ok\"><ping " 367 "appid=\"foo\" status=\"ok\"><ping "
361 "status=\"ok\"/></app></gupdate>", 368 "status=\"ok\"/></app></gupdate>",
362 false, 369 false,
363 &response, 370 &response,
364 NULL)); 371 NULL));
365 EXPECT_FALSE(response.update_exists); 372 EXPECT_FALSE(response.update_exists);
366 } 373 }
367 374
368 TEST(OmahaRequestActionTest, MissingFieldTest) { 375 TEST(OmahaRequestActionTest, MissingFieldTest) {
369 OmahaRequestParams params("machine_id", 376 OmahaRequestParams params("machine_id",
370 "user_id", 377 "user_id",
371 OmahaRequestParams::kOsPlatform, 378 OmahaRequestParams::kOsPlatform,
372 OmahaRequestParams::kOsVersion, 379 OmahaRequestParams::kOsVersion,
373 "service_pack", 380 "service_pack",
374 "x86-generic", 381 "x86-generic",
375 OmahaRequestParams::kAppId, 382 OmahaRequestParams::kAppId,
376 "0.1.0.0", 383 "0.1.0.0",
377 "en-US", 384 "en-US",
378 "unittest_track", 385 "unittest_track",
386 false, // delta okay
379 "http://url"); 387 "http://url");
380 OmahaResponse response; 388 OmahaResponse response;
381 ASSERT_TRUE(TestUpdateCheck(params, 389 ASSERT_TRUE(TestUpdateCheck(params,
382 string("<?xml version=\"1.0\" " 390 string("<?xml version=\"1.0\" "
383 "encoding=\"UTF-8\"?><gupdate " 391 "encoding=\"UTF-8\"?><gupdate "
384 "xmlns=\"http://www.google.com/" 392 "xmlns=\"http://www.google.com/"
385 "update2/response\" " 393 "update2/response\" "
386 "protocol=\"2.0\"><app appid=\"") + 394 "protocol=\"2.0\"><app appid=\"") +
387 OmahaRequestParams::kAppId 395 OmahaRequestParams::kAppId
388 + "\" status=\"ok\"><ping " 396 + "\" status=\"ok\"><ping "
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 OmahaRequestParams params("", // machine_id 438 OmahaRequestParams params("", // machine_id
431 "", // usr_id 439 "", // usr_id
432 OmahaRequestParams::kOsPlatform, 440 OmahaRequestParams::kOsPlatform,
433 OmahaRequestParams::kOsVersion, 441 OmahaRequestParams::kOsVersion,
434 "", // os_sp 442 "", // os_sp
435 "", // os_board 443 "", // os_board
436 OmahaRequestParams::kAppId, 444 OmahaRequestParams::kAppId,
437 "0.1.0.0", 445 "0.1.0.0",
438 "en-US", 446 "en-US",
439 "unittest", 447 "unittest",
448 false, // delta okay
440 "http://url"); 449 "http://url");
441 string http_response("doesn't matter"); 450 string http_response("doesn't matter");
442 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); 451 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
443 452
444 OmahaRequestAction action(params, NULL, 453 OmahaRequestAction action(params, NULL,
445 new MockHttpFetcher(http_response.data(), 454 new MockHttpFetcher(http_response.data(),
446 http_response.size())); 455 http_response.size()));
447 TerminateEarlyTestProcessorDelegate delegate; 456 TerminateEarlyTestProcessorDelegate delegate;
448 delegate.loop_ = loop; 457 delegate.loop_ = loop;
449 ActionProcessor processor; 458 ActionProcessor processor;
(...skipping 18 matching lines...) Expand all
468 OmahaRequestParams params("testthemachine<id", 477 OmahaRequestParams params("testthemachine<id",
469 "testtheuser_id&lt;", 478 "testtheuser_id&lt;",
470 OmahaRequestParams::kOsPlatform, 479 OmahaRequestParams::kOsPlatform,
471 OmahaRequestParams::kOsVersion, 480 OmahaRequestParams::kOsVersion,
472 "testtheservice_pack>", 481 "testtheservice_pack>",
473 "x86 generic", 482 "x86 generic",
474 OmahaRequestParams::kAppId, 483 OmahaRequestParams::kAppId,
475 "0.1.0.0", 484 "0.1.0.0",
476 "en-US", 485 "en-US",
477 "unittest_track", 486 "unittest_track",
487 false, // delta okay
478 "http://url"); 488 "http://url");
479 OmahaResponse response; 489 OmahaResponse response;
480 ASSERT_FALSE( 490 ASSERT_FALSE(
481 TestUpdateCheck(params, 491 TestUpdateCheck(params,
482 "invalid xml>", 492 "invalid xml>",
483 false, 493 false,
484 &response, 494 &response,
485 &post_data)); 495 &post_data));
486 // convert post_data to string 496 // convert post_data to string
487 string post_str(&post_data[0], post_data.size()); 497 string post_str(&post_data[0], post_data.size());
(...skipping 10 matching lines...) Expand all
498 OmahaRequestParams params("machine_id", 508 OmahaRequestParams params("machine_id",
499 "user_id", 509 "user_id",
500 OmahaRequestParams::kOsPlatform, 510 OmahaRequestParams::kOsPlatform,
501 OmahaRequestParams::kOsVersion, 511 OmahaRequestParams::kOsVersion,
502 "service_pack", 512 "service_pack",
503 "x86-generic", 513 "x86-generic",
504 OmahaRequestParams::kAppId, 514 OmahaRequestParams::kAppId,
505 "0.1.0.0", 515 "0.1.0.0",
506 "en-US", 516 "en-US",
507 "unittest_track", 517 "unittest_track",
518 false, // delta okay
508 "http://url"); 519 "http://url");
509 OmahaResponse response; 520 OmahaResponse response;
510 ASSERT_TRUE( 521 ASSERT_TRUE(
511 TestUpdateCheck(params, 522 TestUpdateCheck(params,
512 GetUpdateResponse(OmahaRequestParams::kAppId, 523 GetUpdateResponse(OmahaRequestParams::kAppId,
513 "1.2.3.4", // version 524 "1.2.3.4", // version
514 "testthe&lt;url", // more info 525 "testthe&lt;url", // more info
515 "true", // prompt 526 "true", // prompt
516 "testthe&amp;codebase", // dl url 527 "testthe&amp;codebase", // dl url
517 "HASH1234=", // checksum 528 "HASH1234=", // checksum
(...skipping 11 matching lines...) Expand all
529 OmahaRequestParams params("machine_id", 540 OmahaRequestParams params("machine_id",
530 "user_id", 541 "user_id",
531 OmahaRequestParams::kOsPlatform, 542 OmahaRequestParams::kOsPlatform,
532 OmahaRequestParams::kOsVersion, 543 OmahaRequestParams::kOsVersion,
533 "service_pack", 544 "service_pack",
534 "the_board", 545 "the_board",
535 OmahaRequestParams::kAppId, 546 OmahaRequestParams::kAppId,
536 "0.1.0.0", 547 "0.1.0.0",
537 "en-US", 548 "en-US",
538 "unittest_track", 549 "unittest_track",
550 false, // delta okay
539 "http://url"); 551 "http://url");
540 OmahaResponse response; 552 OmahaResponse response;
541 ASSERT_TRUE( 553 ASSERT_TRUE(
542 TestUpdateCheck(params, 554 TestUpdateCheck(params,
543 GetUpdateResponse(OmahaRequestParams::kAppId, 555 GetUpdateResponse(OmahaRequestParams::kAppId,
544 "1.2.3.4", // version 556 "1.2.3.4", // version
545 "theurl", // more info 557 "theurl", // more info
546 "true", // prompt 558 "true", // prompt
547 "thecodebase", // dl url 559 "thecodebase", // dl url
548 "HASH1234=", // checksum 560 "HASH1234=", // checksum
(...skipping 12 matching lines...) Expand all
561 OmahaRequestParams params("machine_id", 573 OmahaRequestParams params("machine_id",
562 "user_id", 574 "user_id",
563 OmahaRequestParams::kOsPlatform, 575 OmahaRequestParams::kOsPlatform,
564 OmahaRequestParams::kOsVersion, 576 OmahaRequestParams::kOsVersion,
565 "service_pack", 577 "service_pack",
566 "x86-generic", 578 "x86-generic",
567 OmahaRequestParams::kAppId, 579 OmahaRequestParams::kAppId,
568 "0.1.0.0", 580 "0.1.0.0",
569 "en-US", 581 "en-US",
570 "unittest_track", 582 "unittest_track",
583 false, // delta okay
571 "http://url"); 584 "http://url");
572 OmahaResponse response; 585 OmahaResponse response;
573 ASSERT_FALSE(TestUpdateCheck(params, 586 ASSERT_FALSE(TestUpdateCheck(params,
574 "invalid xml>", 587 "invalid xml>",
575 false, 588 false,
576 &response, 589 &response,
577 &post_data)); 590 &post_data));
578 // convert post_data to string 591 // convert post_data to string
579 string post_str(&post_data[0], post_data.size()); 592 string post_str(&post_data[0], post_data.size());
580 EXPECT_NE(post_str.find(" <o:ping active=\"0\"></o:ping>\n" 593 EXPECT_NE(post_str.find(" <o:ping active=\"0\"></o:ping>\n"
581 " <o:updatecheck></o:updatecheck>\n"), 594 " <o:updatecheck></o:updatecheck>\n"),
582 string::npos); 595 string::npos);
583 EXPECT_EQ(post_str.find("o:event"), string::npos); 596 EXPECT_EQ(post_str.find("o:event"), string::npos);
584 } 597 }
585 598
586 TEST(OmahaRequestActionTest, FormatEventOutputTest) { 599 TEST(OmahaRequestActionTest, FormatEventOutputTest) {
587 vector<char> post_data; 600 vector<char> post_data;
588 OmahaRequestParams params("machine_id", 601 OmahaRequestParams params("machine_id",
589 "user_id", 602 "user_id",
590 OmahaRequestParams::kOsPlatform, 603 OmahaRequestParams::kOsPlatform,
591 OmahaRequestParams::kOsVersion, 604 OmahaRequestParams::kOsVersion,
592 "service_pack", 605 "service_pack",
593 "x86-generic", 606 "x86-generic",
594 OmahaRequestParams::kAppId, 607 OmahaRequestParams::kAppId,
595 "0.1.0.0", 608 "0.1.0.0",
596 "en-US", 609 "en-US",
597 "unittest_track", 610 "unittest_track",
611 false, // delta okay
598 "http://url"); 612 "http://url");
599 TestEvent(params, 613 TestEvent(params,
600 new OmahaEvent(OmahaEvent::kTypeDownloadComplete, 614 new OmahaEvent(OmahaEvent::kTypeDownloadComplete,
601 OmahaEvent::kResultError, 615 OmahaEvent::kResultError,
602 5), 616 5),
603 "invalid xml>", 617 "invalid xml>",
604 &post_data); 618 &post_data);
605 // convert post_data to string 619 // convert post_data to string
606 string post_str(&post_data[0], post_data.size()); 620 string post_str(&post_data[0], post_data.size());
607 string expected_event = StringPrintf( 621 string expected_event = StringPrintf(
(...skipping 11 matching lines...) Expand all
619 OmahaRequestParams params("machine_id", 633 OmahaRequestParams params("machine_id",
620 "user_id", 634 "user_id",
621 OmahaRequestParams::kOsPlatform, 635 OmahaRequestParams::kOsPlatform,
622 OmahaRequestParams::kOsVersion, 636 OmahaRequestParams::kOsVersion,
623 "service_pack", 637 "service_pack",
624 "x86-generic", 638 "x86-generic",
625 OmahaRequestParams::kAppId, 639 OmahaRequestParams::kAppId,
626 "0.1.0.0", 640 "0.1.0.0",
627 "en-US", 641 "en-US",
628 "unittest_track", 642 "unittest_track",
643 false, // delta okay
629 "http://url"); 644 "http://url");
630 645
631 OmahaRequestAction update_check_action( 646 OmahaRequestAction update_check_action(
632 params, 647 params,
633 NULL, 648 NULL,
634 new MockHttpFetcher(http_response.data(), 649 new MockHttpFetcher(http_response.data(),
635 http_response.size())); 650 http_response.size()));
636 EXPECT_FALSE(update_check_action.IsEvent()); 651 EXPECT_FALSE(update_check_action.IsEvent());
637 652
638 OmahaRequestAction event_action( 653 OmahaRequestAction event_action(
639 params, 654 params,
640 new OmahaEvent(OmahaEvent::kTypeInstallComplete, 655 new OmahaEvent(OmahaEvent::kTypeInstallComplete,
641 OmahaEvent::kResultError, 656 OmahaEvent::kResultError,
642 0), 657 0),
643 new MockHttpFetcher(http_response.data(), 658 new MockHttpFetcher(http_response.data(),
644 http_response.size())); 659 http_response.size()));
645 EXPECT_TRUE(event_action.IsEvent()); 660 EXPECT_TRUE(event_action.IsEvent());
646 } 661 }
647 662
663 TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) {
664 for (int i = 0; i < 2; i++) {
665 bool delta_okay = i == 1;
666 const char* delta_okay_str = delta_okay ? "true" : "false";
667 vector<char> post_data;
668 OmahaRequestParams params("machine_id",
669 "user_id",
670 OmahaRequestParams::kOsPlatform,
671 OmahaRequestParams::kOsVersion,
672 "service_pack",
673 "x86-generic",
674 OmahaRequestParams::kAppId,
675 "0.1.0.0",
676 "en-US",
677 "unittest_track",
678 delta_okay,
679 "http://url");
680 ASSERT_FALSE(TestUpdateCheck(params,
681 "invalid xml>",
682 false,
683 NULL,
684 &post_data));
685 // convert post_data to string
686 string post_str(&post_data[0], post_data.size());
687 EXPECT_NE(post_str.find(StringPrintf(" delta_okay=\"%s\"", delta_okay_str)),
688 string::npos)
689 << "i = " << i;
690 }
691 }
692
648 } // namespace chromeos_update_engine 693 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « omaha_request_action.cc ('k') | omaha_request_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698