| OLD | NEW |
| 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/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 524 } |
| 525 | 525 |
| 526 // Tests the interaction with the HTTP cache. | 526 // Tests the interaction with the HTTP cache. |
| 527 TEST_F(MalwareDetailsTest, HTTPCache) { | 527 TEST_F(MalwareDetailsTest, HTTPCache) { |
| 528 controller().LoadURL(GURL(kLandingURL), content::Referrer(), | 528 controller().LoadURL(GURL(kLandingURL), content::Referrer(), |
| 529 content::PAGE_TRANSITION_TYPED, std::string()); | 529 content::PAGE_TRANSITION_TYPED, std::string()); |
| 530 | 530 |
| 531 UnsafeResource resource; | 531 UnsafeResource resource; |
| 532 InitResource(&resource, true, GURL(kMalwareURL)); | 532 InitResource(&resource, true, GURL(kMalwareURL)); |
| 533 | 533 |
| 534 profile()->CreateRequestContext(); | |
| 535 scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap( | 534 scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap( |
| 536 ui_manager_.get(), web_contents(), resource, | 535 ui_manager_.get(), web_contents(), resource, |
| 537 profile()->GetRequestContext()); | 536 profile()->GetRequestContext()); |
| 538 | 537 |
| 539 BrowserThread::PostTask( | 538 BrowserThread::PostTask( |
| 540 BrowserThread::IO, FROM_HERE, | 539 BrowserThread::IO, FROM_HERE, |
| 541 base::Bind(&FillCache, | 540 base::Bind(&FillCache, |
| 542 make_scoped_refptr(profile()->GetRequestContext()))); | 541 make_scoped_refptr(profile()->GetRequestContext()))); |
| 543 | 542 |
| 544 // The cache collection starts after the IPC from the DOM is fired. | 543 // The cache collection starts after the IPC from the DOM is fired. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 pb_header = pb_response->add_headers(); | 586 pb_header = pb_response->add_headers(); |
| 588 pb_header->set_name("Content-Type"); | 587 pb_header->set_name("Content-Type"); |
| 589 pb_header->set_value("image/jpeg"); | 588 pb_header->set_value("image/jpeg"); |
| 590 pb_response->set_body(kMalwareData); | 589 pb_response->set_body(kMalwareData); |
| 591 pb_response->set_bodylength(10); | 590 pb_response->set_bodylength(10); |
| 592 pb_response->set_bodydigest("581373551c43d4cf33bfb3b26838ff95"); | 591 pb_response->set_bodydigest("581373551c43d4cf33bfb3b26838ff95"); |
| 593 pb_response->set_remote_ip("1.2.3.4:80"); | 592 pb_response->set_remote_ip("1.2.3.4:80"); |
| 594 expected.set_complete(true); | 593 expected.set_complete(true); |
| 595 | 594 |
| 596 VerifyResults(actual, expected); | 595 VerifyResults(actual, expected); |
| 597 profile()->ResetRequestContext(); | |
| 598 } | 596 } |
| 599 | 597 |
| 600 // Tests the interaction with the HTTP cache (where the cache is empty). | 598 // Tests the interaction with the HTTP cache (where the cache is empty). |
| 601 TEST_F(MalwareDetailsTest, HTTPCacheNoEntries) { | 599 TEST_F(MalwareDetailsTest, HTTPCacheNoEntries) { |
| 602 controller().LoadURL(GURL(kLandingURL), content::Referrer(), | 600 controller().LoadURL(GURL(kLandingURL), content::Referrer(), |
| 603 content::PAGE_TRANSITION_TYPED, std::string()); | 601 content::PAGE_TRANSITION_TYPED, std::string()); |
| 604 | 602 |
| 605 UnsafeResource resource; | 603 UnsafeResource resource; |
| 606 InitResource(&resource, true, GURL(kMalwareURL)); | 604 InitResource(&resource, true, GURL(kMalwareURL)); |
| 607 | 605 |
| 608 profile()->CreateRequestContext(); | |
| 609 scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap( | 606 scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap( |
| 610 ui_manager_.get(), web_contents(), resource, | 607 ui_manager_.get(), web_contents(), resource, |
| 611 profile()->GetRequestContext()); | 608 profile()->GetRequestContext()); |
| 612 | 609 |
| 613 // No call to FillCache | 610 // No call to FillCache |
| 614 | 611 |
| 615 // The cache collection starts after the IPC from the DOM is fired. | 612 // The cache collection starts after the IPC from the DOM is fired. |
| 616 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; | 613 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; |
| 617 report->OnReceivedMalwareDOMDetails(params); | 614 report->OnReceivedMalwareDOMDetails(params); |
| 618 | 615 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 pb_resource = expected.add_resources(); | 684 pb_resource = expected.add_resources(); |
| 688 pb_resource->set_id(2); | 685 pb_resource->set_id(2); |
| 689 pb_resource->set_parent_id(3); | 686 pb_resource->set_parent_id(3); |
| 690 pb_resource->set_url(kSecondRedirectURL); | 687 pb_resource->set_url(kSecondRedirectURL); |
| 691 pb_resource = expected.add_resources(); | 688 pb_resource = expected.add_resources(); |
| 692 pb_resource->set_id(3); | 689 pb_resource->set_id(3); |
| 693 pb_resource->set_url(kFirstRedirectURL); | 690 pb_resource->set_url(kFirstRedirectURL); |
| 694 | 691 |
| 695 VerifyResults(actual, expected); | 692 VerifyResults(actual, expected); |
| 696 } | 693 } |
| OLD | NEW |