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

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

Issue 636673002: Remove navigation from TestRenderViewHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes from self-review Created 6 years, 2 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 26 matching lines...) Expand all
37 using ::testing::IsNull; 37 using ::testing::IsNull;
38 using ::testing::Mock; 38 using ::testing::Mock;
39 using ::testing::NiceMock; 39 using ::testing::NiceMock;
40 using ::testing::NotNull; 40 using ::testing::NotNull;
41 using ::testing::Pointee; 41 using ::testing::Pointee;
42 using ::testing::Return; 42 using ::testing::Return;
43 using ::testing::SaveArg; 43 using ::testing::SaveArg;
44 using ::testing::SetArgumentPointee; 44 using ::testing::SetArgumentPointee;
45 using ::testing::StrictMock; 45 using ::testing::StrictMock;
46 using content::BrowserThread; 46 using content::BrowserThread;
47 using content::RenderViewHostTester; 47 using content::RenderFrameHostTester;
48 using content::ResourceType; 48 using content::ResourceType;
49 using content::WebContents; 49 using content::WebContents;
50 50
51 namespace { 51 namespace {
52 52
53 const bool kFalse = false; 53 const bool kFalse = false;
54 const bool kTrue = true; 54 const bool kTrue = true;
55 55
56 } // namespace 56 } // namespace
57 57
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 NavigateAndCommit(inpage); 939 NavigateAndCommit(inpage);
940 WaitAndCheckPreClassificationChecks(); 940 WaitAndCheckPreClassificationChecks();
941 941
942 ExpectStartPhishingDetection(NULL); 942 ExpectStartPhishingDetection(NULL);
943 ExpectShouldClassifyForMalwareResult(true); 943 ExpectShouldClassifyForMalwareResult(true);
944 } 944 }
945 945
946 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckXHTML) { 946 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckXHTML) {
947 // Check that XHTML is supported, in addition to the default HTML type. 947 // Check that XHTML is supported, in addition to the default HTML type.
948 GURL url("http://host.com/xhtml"); 948 GURL url("http://host.com/xhtml");
949 rvh_tester()->SetContentsMimeType("application/xhtml+xml"); 949 RenderFrameHostTester::For(main_rfh())->
950 SetContentsMimeType("application/xhtml+xml");
950 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, 951 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse,
951 &kFalse, &kFalse, &kFalse, &kFalse); 952 &kFalse, &kFalse, &kFalse, &kFalse);
952 NavigateAndCommit(url); 953 NavigateAndCommit(url);
953 WaitAndCheckPreClassificationChecks(); 954 WaitAndCheckPreClassificationChecks();
954 955
955 ExpectStartPhishingDetection(&url); 956 ExpectStartPhishingDetection(&url);
956 ExpectShouldClassifyForMalwareResult(true); 957 ExpectShouldClassifyForMalwareResult(true);
957 } 958 }
958 959
959 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckTwoNavigations) { 960 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckTwoNavigations) {
(...skipping 18 matching lines...) Expand all
978 } 979 }
979 980
980 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckMimeType) { 981 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckMimeType) {
981 // If the mime type is not one that we support, no IPC should be triggered 982 // If the mime type is not one that we support, no IPC should be triggered
982 // but all pre-classification checks should run because we might classify 983 // but all pre-classification checks should run because we might classify
983 // other mime types for malware. 984 // other mime types for malware.
984 // Note: for this test to work correctly, the new URL must be on the 985 // Note: for this test to work correctly, the new URL must be on the
985 // same domain as the previous URL, otherwise it will create a new 986 // same domain as the previous URL, otherwise it will create a new
986 // RenderViewHost that won't have the mime type set. 987 // RenderViewHost that won't have the mime type set.
987 GURL url("http://host2.com/image.jpg"); 988 GURL url("http://host2.com/image.jpg");
988 rvh_tester()->SetContentsMimeType("image/jpeg"); 989 RenderFrameHostTester::For(web_contents()->GetMainFrame())->
Charlie Reis 2014/10/08 17:41:55 Why are some of these using main_rfh() and others
ncarter (slow) 2014/10/08 22:39:28 Done. I've switched these over to be web_contents(
990 SetContentsMimeType("image/jpeg");
989 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, 991 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse,
990 &kFalse, &kFalse, &kFalse, &kFalse); 992 &kFalse, &kFalse, &kFalse, &kFalse);
991 NavigateAndCommit(url); 993 NavigateAndCommit(url);
992 WaitAndCheckPreClassificationChecks(); 994 WaitAndCheckPreClassificationChecks();
993 995
994 ExpectStartPhishingDetection(NULL); 996 ExpectStartPhishingDetection(NULL);
995 ExpectShouldClassifyForMalwareResult(true); 997 ExpectShouldClassifyForMalwareResult(true);
996 } 998 }
997 999
998 TEST_F(ClientSideDetectionHostTest, 1000 TEST_F(ClientSideDetectionHostTest,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 EXPECT_EQ(url, resource.url); 1143 EXPECT_EQ(url, resource.url);
1142 EXPECT_EQ(url, resource.original_url); 1144 EXPECT_EQ(url, resource.original_url);
1143 1145
1144 ExpectStartPhishingDetection(NULL); 1146 ExpectStartPhishingDetection(NULL);
1145 1147
1146 // Showing a phishing warning will invalidate all the weak pointers which 1148 // Showing a phishing warning will invalidate all the weak pointers which
1147 // means we will not extract malware features. 1149 // means we will not extract malware features.
1148 ExpectShouldClassifyForMalwareResult(false); 1150 ExpectShouldClassifyForMalwareResult(false);
1149 } 1151 }
1150 } // namespace safe_browsing 1152 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698