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

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

Issue 7016047: Fix TestURLRequestContext leaks in MalwareDetailsTest.HTTPCache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/pickle.h" 7 #include "base/pickle.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/safe_browsing/malware_details.h" 10 #include "chrome/browser/safe_browsing/malware_details.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 WriteHeaders(entry, headers); 98 WriteHeaders(entry, headers);
99 WriteData(entry, data); 99 WriteData(entry, data);
100 entry->Close(); 100 entry->Close();
101 } 101 }
102 102
103 void FillCache(net::URLRequestContextGetter* context_getter) { 103 void FillCache(net::URLRequestContextGetter* context_getter) {
104 TestCompletionCallback cb; 104 TestCompletionCallback cb;
105 disk_cache::Backend* cache; 105 disk_cache::Backend* cache;
106 int rv = 106 int rv =
107 context_getter->GetURLRequestContext()->http_transaction_factory()-> 107 context_getter->GetURLRequestContext()->http_transaction_factory()->
108 GetCache()-> GetBackend(&cache, &cb); 108 GetCache()->GetBackend(&cache, &cb);
109 ASSERT_EQ(net::OK, cb.GetResult(rv)); 109 ASSERT_EQ(net::OK, cb.GetResult(rv));
110 110
111 std::string empty; 111 std::string empty;
112 WriteToEntry(cache, kMalwareURL, kMalwareHeaders, kMalwareData); 112 WriteToEntry(cache, kMalwareURL, kMalwareHeaders, kMalwareData);
113 WriteToEntry(cache, kLandingURL, kLandingHeaders, kLandingData); 113 WriteToEntry(cache, kLandingURL, kLandingHeaders, kLandingData);
114 } 114 }
115 115
116 void QuitUIMessageLoop() { 116 void QuitUIMessageLoop() {
117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
118 BrowserThread::PostTask(BrowserThread::UI, 118 BrowserThread::PostTask(BrowserThread::UI,
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 pb_header = pb_response->add_headers(); 552 pb_header = pb_response->add_headers();
553 pb_header->set_name("Content-Type"); 553 pb_header->set_name("Content-Type");
554 pb_header->set_value("image/jpeg"); 554 pb_header->set_value("image/jpeg");
555 pb_response->set_body(kMalwareData); 555 pb_response->set_body(kMalwareData);
556 pb_response->set_bodylength(10); 556 pb_response->set_bodylength(10);
557 pb_response->set_bodydigest("581373551c43d4cf33bfb3b26838ff95"); 557 pb_response->set_bodydigest("581373551c43d4cf33bfb3b26838ff95");
558 pb_response->set_remote_ip("1.2.3.4:80"); 558 pb_response->set_remote_ip("1.2.3.4:80");
559 expected.set_complete(true); 559 expected.set_complete(true);
560 560
561 VerifyResults(actual, expected); 561 VerifyResults(actual, expected);
562 profile()->ResetRequestContext();
562 } 563 }
563 564
564 // Tests the interaction with the HTTP cache (where the cache is empty). 565 // Tests the interaction with the HTTP cache (where the cache is empty).
565 TEST_F(MalwareDetailsTest, HTTPCacheNoEntries) { 566 TEST_F(MalwareDetailsTest, HTTPCacheNoEntries) {
566 controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED); 567 controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
567 568
568 SafeBrowsingService::UnsafeResource resource; 569 SafeBrowsingService::UnsafeResource resource;
569 InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL)); 570 InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
570 571
571 profile()->CreateRequestContext(); 572 profile()->CreateRequestContext();
(...skipping 23 matching lines...) Expand all
595 ClientMalwareReportRequest::Resource* pb_resource = expected.add_resources(); 596 ClientMalwareReportRequest::Resource* pb_resource = expected.add_resources();
596 pb_resource->set_id(0); 597 pb_resource->set_id(0);
597 pb_resource->set_url(kLandingURL); 598 pb_resource->set_url(kLandingURL);
598 pb_resource = expected.add_resources(); 599 pb_resource = expected.add_resources();
599 pb_resource->set_id(1); 600 pb_resource->set_id(1);
600 pb_resource->set_url(kMalwareURL); 601 pb_resource->set_url(kMalwareURL);
601 expected.set_complete(true); 602 expected.set_complete(true);
602 603
603 VerifyResults(actual, expected); 604 VerifyResults(actual, expected);
604 } 605 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698