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

Side by Side Diff: chrome/browser/safe_browsing/malware_details_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 child_node.url = GURL(kDOMChildURL); 405 child_node.url = GURL(kDOMChildURL);
406 child_node.tag_name = "iframe"; 406 child_node.tag_name = "iframe";
407 child_node.parent = GURL(kDOMParentURL); 407 child_node.parent = GURL(kDOMParentURL);
408 params.push_back(child_node); 408 params.push_back(child_node);
409 SafeBrowsingHostMsg_MalwareDOMDetails_Node parent_node; 409 SafeBrowsingHostMsg_MalwareDOMDetails_Node parent_node;
410 parent_node.url = GURL(kDOMParentURL); 410 parent_node.url = GURL(kDOMParentURL);
411 parent_node.children.push_back(GURL(kDOMChildURL)); 411 parent_node.children.push_back(GURL(kDOMChildURL));
412 params.push_back(parent_node); 412 params.push_back(parent_node);
413 report->OnReceivedMalwareDOMDetails(params); 413 report->OnReceivedMalwareDOMDetails(params);
414 414
415 MessageLoop::current()->RunAllPending(); 415 MessageLoop::current()->RunUntilIdle();
416 416
417 std::string serialized = WaitForSerializedReport(report); 417 std::string serialized = WaitForSerializedReport(report);
418 ClientMalwareReportRequest actual; 418 ClientMalwareReportRequest actual;
419 actual.ParseFromString(serialized); 419 actual.ParseFromString(serialized);
420 420
421 ClientMalwareReportRequest expected; 421 ClientMalwareReportRequest expected;
422 expected.set_malware_url(kMalwareURL); 422 expected.set_malware_url(kMalwareURL);
423 expected.set_page_url(kLandingURL); 423 expected.set_page_url(kLandingURL);
424 expected.set_referrer_url(""); 424 expected.set_referrer_url("");
425 425
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 BrowserThread::PostTask( 537 BrowserThread::PostTask(
538 BrowserThread::IO, FROM_HERE, 538 BrowserThread::IO, FROM_HERE,
539 base::Bind(&FillCache, 539 base::Bind(&FillCache,
540 make_scoped_refptr(profile()->GetRequestContext()))); 540 make_scoped_refptr(profile()->GetRequestContext())));
541 541
542 // The cache collection starts after the IPC from the DOM is fired. 542 // The cache collection starts after the IPC from the DOM is fired.
543 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; 543 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params;
544 report->OnReceivedMalwareDOMDetails(params); 544 report->OnReceivedMalwareDOMDetails(params);
545 545
546 // Let the cache callbacks complete 546 // Let the cache callbacks complete
547 MessageLoop::current()->RunAllPending(); 547 MessageLoop::current()->RunUntilIdle();
548 548
549 DVLOG(1) << "Getting serialized report"; 549 DVLOG(1) << "Getting serialized report";
550 std::string serialized = WaitForSerializedReport(report); 550 std::string serialized = WaitForSerializedReport(report);
551 ClientMalwareReportRequest actual; 551 ClientMalwareReportRequest actual;
552 actual.ParseFromString(serialized); 552 actual.ParseFromString(serialized);
553 553
554 ClientMalwareReportRequest expected; 554 ClientMalwareReportRequest expected;
555 expected.set_malware_url(kMalwareURL); 555 expected.set_malware_url(kMalwareURL);
556 expected.set_page_url(kLandingURL); 556 expected.set_page_url(kLandingURL);
557 expected.set_referrer_url(""); 557 expected.set_referrer_url("");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 sb_service_.get(), web_contents(), resource, 608 sb_service_.get(), web_contents(), resource,
609 profile()->GetRequestContext()); 609 profile()->GetRequestContext());
610 610
611 // No call to FillCache 611 // No call to FillCache
612 612
613 // The cache collection starts after the IPC from the DOM is fired. 613 // The cache collection starts after the IPC from the DOM is fired.
614 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; 614 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params;
615 report->OnReceivedMalwareDOMDetails(params); 615 report->OnReceivedMalwareDOMDetails(params);
616 616
617 // Let the cache callbacks complete 617 // Let the cache callbacks complete
618 MessageLoop::current()->RunAllPending(); 618 MessageLoop::current()->RunUntilIdle();
619 619
620 DVLOG(1) << "Getting serialized report"; 620 DVLOG(1) << "Getting serialized report";
621 std::string serialized = WaitForSerializedReport(report); 621 std::string serialized = WaitForSerializedReport(report);
622 ClientMalwareReportRequest actual; 622 ClientMalwareReportRequest actual;
623 actual.ParseFromString(serialized); 623 actual.ParseFromString(serialized);
624 624
625 ClientMalwareReportRequest expected; 625 ClientMalwareReportRequest expected;
626 expected.set_malware_url(kMalwareURL); 626 expected.set_malware_url(kMalwareURL);
627 expected.set_page_url(kLandingURL); 627 expected.set_page_url(kLandingURL);
628 expected.set_referrer_url(""); 628 expected.set_referrer_url("");
(...skipping 28 matching lines...) Expand all
657 SafeBrowsingService::UnsafeResource resource; 657 SafeBrowsingService::UnsafeResource resource;
658 InitResource(&resource, true, GURL(kMalwareURL)); 658 InitResource(&resource, true, GURL(kMalwareURL));
659 scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap( 659 scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
660 sb_service_.get(), web_contents(), resource, NULL); 660 sb_service_.get(), web_contents(), resource, NULL);
661 661
662 // The redirects collection starts after the IPC from the DOM is fired. 662 // The redirects collection starts after the IPC from the DOM is fired.
663 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; 663 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params;
664 report->OnReceivedMalwareDOMDetails(params); 664 report->OnReceivedMalwareDOMDetails(params);
665 665
666 // Let the redirects callbacks complete. 666 // Let the redirects callbacks complete.
667 MessageLoop::current()->RunAllPending(); 667 MessageLoop::current()->RunUntilIdle();
668 668
669 std::string serialized = WaitForSerializedReport(report); 669 std::string serialized = WaitForSerializedReport(report);
670 ClientMalwareReportRequest actual; 670 ClientMalwareReportRequest actual;
671 actual.ParseFromString(serialized); 671 actual.ParseFromString(serialized);
672 672
673 ClientMalwareReportRequest expected; 673 ClientMalwareReportRequest expected;
674 expected.set_malware_url(kMalwareURL); 674 expected.set_malware_url(kMalwareURL);
675 expected.set_page_url(kLandingURL); 675 expected.set_page_url(kLandingURL);
676 expected.set_referrer_url(""); 676 expected.set_referrer_url("");
677 677
678 ClientMalwareReportRequest::Resource* pb_resource = expected.add_resources(); 678 ClientMalwareReportRequest::Resource* pb_resource = expected.add_resources();
679 pb_resource->set_id(0); 679 pb_resource->set_id(0);
680 pb_resource->set_url(kLandingURL); 680 pb_resource->set_url(kLandingURL);
681 pb_resource = expected.add_resources(); 681 pb_resource = expected.add_resources();
682 pb_resource->set_id(1); 682 pb_resource->set_id(1);
683 pb_resource->set_parent_id(2); 683 pb_resource->set_parent_id(2);
684 pb_resource->set_url(kMalwareURL); 684 pb_resource->set_url(kMalwareURL);
685 pb_resource = expected.add_resources(); 685 pb_resource = expected.add_resources();
686 pb_resource->set_id(2); 686 pb_resource->set_id(2);
687 pb_resource->set_parent_id(3); 687 pb_resource->set_parent_id(3);
688 pb_resource->set_url(kSecondRedirectURL); 688 pb_resource->set_url(kSecondRedirectURL);
689 pb_resource = expected.add_resources(); 689 pb_resource = expected.add_resources();
690 pb_resource->set_id(3); 690 pb_resource->set_id(3);
691 pb_resource->set_url(kFirstRedirectURL); 691 pb_resource->set_url(kFirstRedirectURL);
692 692
693 VerifyResults(actual, expected); 693 VerifyResults(actual, expected);
694 } 694 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698