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

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

Issue 313073002: Clean-up coding style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 request->CopyFrom(*verdict); 104 request->CopyFrom(*verdict);
105 ::std::tr1::get<2>(args).Run(true, request.Pass()); 105 ::std::tr1::get<2>(args).Run(true, request.Pass());
106 } 106 }
107 107
108 void EmptyUrlCheckCallback(bool processed) { 108 void EmptyUrlCheckCallback(bool processed) {
109 } 109 }
110 110
111 class MockClientSideDetectionService : public ClientSideDetectionService { 111 class MockClientSideDetectionService : public ClientSideDetectionService {
112 public: 112 public:
113 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {} 113 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {}
114 virtual ~MockClientSideDetectionService() {}; 114 virtual ~MockClientSideDetectionService() {}
115 115
116 MOCK_METHOD2(SendClientReportPhishingRequest, 116 MOCK_METHOD2(SendClientReportPhishingRequest,
117 void(ClientPhishingRequest*, 117 void(ClientPhishingRequest*,
118 const ClientReportPhishingRequestCallback&)); 118 const ClientReportPhishingRequestCallback&));
119 MOCK_METHOD2(SendClientReportMalwareRequest, 119 MOCK_METHOD2(SendClientReportMalwareRequest,
120 void(ClientMalwareRequest*, 120 void(ClientMalwareRequest*,
121 const ClientReportMalwareRequestCallback&)); 121 const ClientReportMalwareRequestCallback&));
122 MOCK_CONST_METHOD1(IsPrivateIPAddress, bool(const std::string&)); 122 MOCK_CONST_METHOD1(IsPrivateIPAddress, bool(const std::string&));
123 MOCK_METHOD2(GetValidCachedResult, bool(const GURL&, bool*)); 123 MOCK_METHOD2(GetValidCachedResult, bool(const GURL&, bool*));
124 MOCK_METHOD1(IsInCache, bool(const GURL&)); 124 MOCK_METHOD1(IsInCache, bool(const GURL&));
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckMimeType) { 982 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckMimeType) {
983 // If the mime type is not one that we support, no IPC should be triggered 983 // If the mime type is not one that we support, no IPC should be triggered
984 // but all pre-classification checks should run because we might classify 984 // but all pre-classification checks should run because we might classify
985 // other mime types for malware. 985 // other mime types for malware.
986 // Note: for this test to work correctly, the new URL must be on the 986 // Note: for this test to work correctly, the new URL must be on the
987 // same domain as the previous URL, otherwise it will create a new 987 // same domain as the previous URL, otherwise it will create a new
988 // RenderViewHost that won't have the mime type set. 988 // RenderViewHost that won't have the mime type set.
989 GURL url("http://host2.com/image.jpg"); 989 GURL url("http://host2.com/image.jpg");
990 rvh_tester()->SetContentsMimeType("image/jpeg"); 990 rvh_tester()->SetContentsMimeType("image/jpeg");
991 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, 991 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse,
992 &kFalse, &kFalse,&kFalse, &kFalse); 992 &kFalse, &kFalse, &kFalse, &kFalse);
993 NavigateAndCommit(url); 993 NavigateAndCommit(url);
994 WaitAndCheckPreClassificationChecks(); 994 WaitAndCheckPreClassificationChecks();
995 995
996 ExpectStartPhishingDetection(NULL); 996 ExpectStartPhishingDetection(NULL);
997 ExpectShouldClassifyForMalwareResult(true); 997 ExpectShouldClassifyForMalwareResult(true);
998 } 998 }
999 999
1000 TEST_F(ClientSideDetectionHostTest, 1000 TEST_F(ClientSideDetectionHostTest,
1001 TestPreClassificationCheckPrivateIpAddress) { 1001 TestPreClassificationCheckPrivateIpAddress) {
1002 // If IsPrivateIPAddress returns true, no IPC should be triggered. 1002 // If IsPrivateIPAddress returns true, no IPC should be triggered.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 EXPECT_EQ(url, resource.url); 1143 EXPECT_EQ(url, resource.url);
1144 EXPECT_EQ(url, resource.original_url); 1144 EXPECT_EQ(url, resource.original_url);
1145 1145
1146 ExpectStartPhishingDetection(NULL); 1146 ExpectStartPhishingDetection(NULL);
1147 1147
1148 // Showing a phishing warning will invalidate all the weak pointers which 1148 // Showing a phishing warning will invalidate all the weak pointers which
1149 // means we will not extract malware features. 1149 // means we will not extract malware features.
1150 ExpectShouldClassifyForMalwareResult(false); 1150 ExpectShouldClassifyForMalwareResult(false);
1151 } 1151 }
1152 } // namespace safe_browsing 1152 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698