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

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

Issue 9706012: Add abstractions that let embedders drive tests of WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove CONTENT_EXPORT on statically linked functions. Merge to head for commit. Created 8 years, 9 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
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/file_path.h" 5 #include "base/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/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" 9 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
10 #include "chrome/browser/safe_browsing/client_side_detection_host.h" 10 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
11 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 11 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
14 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/safe_browsing/csd.pb.h" 16 #include "chrome/common/safe_browsing/csd.pb.h"
17 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 17 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "content/browser/tab_contents/test_tab_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "content/test/mock_render_process_host.h" 20 #include "content/test/mock_render_process_host.h"
21 #include "content/test/test_browser_thread.h" 21 #include "content/test/test_browser_thread.h"
22 #include "content/test/test_renderer_host.h" 22 #include "content/test/test_renderer_host.h"
23 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
24 #include "ipc/ipc_test_sink.h" 24 #include "ipc/ipc_test_sink.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 using ::testing::_; 28 using ::testing::_;
29 using ::testing::DeleteArg; 29 using ::testing::DeleteArg;
30 using ::testing::DoAll; 30 using ::testing::DoAll;
31 using ::testing::Eq; 31 using ::testing::Eq;
32 using ::testing::IsNull; 32 using ::testing::IsNull;
33 using ::testing::Mock; 33 using ::testing::Mock;
34 using ::testing::NiceMock; 34 using ::testing::NiceMock;
35 using ::testing::NotNull; 35 using ::testing::NotNull;
36 using ::testing::Pointee; 36 using ::testing::Pointee;
37 using ::testing::Return; 37 using ::testing::Return;
38 using ::testing::SaveArg; 38 using ::testing::SaveArg;
39 using ::testing::SetArgumentPointee; 39 using ::testing::SetArgumentPointee;
40 using ::testing::StrictMock; 40 using ::testing::StrictMock;
41 using content::BrowserThread; 41 using content::BrowserThread;
42 using content::RenderViewHostTester; 42 using content::RenderViewHostTester;
43 using content::WebContents;
43 44
44 namespace { 45 namespace {
45 const bool kFalse = false; 46 const bool kFalse = false;
46 const bool kTrue = true; 47 const bool kTrue = true;
47 } 48 }
48 49
49 namespace safe_browsing { 50 namespace safe_browsing {
50 namespace { 51 namespace {
51 // This matcher verifies that the client computed verdict 52 // This matcher verifies that the client computed verdict
52 // (ClientPhishingRequest) which is passed to SendClientReportPhishingRequest 53 // (ClientPhishingRequest) which is passed to SendClientReportPhishingRequest
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 public: 125 public:
125 MockTestingProfile() {} 126 MockTestingProfile() {}
126 virtual ~MockTestingProfile() {} 127 virtual ~MockTestingProfile() {}
127 128
128 MOCK_CONST_METHOD0(IsOffTheRecord, bool()); 129 MOCK_CONST_METHOD0(IsOffTheRecord, bool());
129 }; 130 };
130 131
131 class MockBrowserFeatureExtractor : public BrowserFeatureExtractor { 132 class MockBrowserFeatureExtractor : public BrowserFeatureExtractor {
132 public: 133 public:
133 explicit MockBrowserFeatureExtractor( 134 explicit MockBrowserFeatureExtractor(
134 TabContents* tab, 135 WebContents* tab,
135 ClientSideDetectionService* service) 136 ClientSideDetectionService* service)
136 : BrowserFeatureExtractor(tab, service) {} 137 : BrowserFeatureExtractor(tab, service) {}
137 virtual ~MockBrowserFeatureExtractor() {} 138 virtual ~MockBrowserFeatureExtractor() {}
138 139
139 MOCK_METHOD3(ExtractFeatures, 140 MOCK_METHOD3(ExtractFeatures,
140 void(const BrowseInfo* info, 141 void(const BrowseInfo* info,
141 ClientPhishingRequest*, 142 ClientPhishingRequest*,
142 const BrowserFeatureExtractor::DoneCallback&)); 143 const BrowserFeatureExtractor::DoneCallback&));
143 }; 144 };
144 145
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); 776 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get()));
776 EXPECT_EQ(url, resource.url); 777 EXPECT_EQ(url, resource.url);
777 EXPECT_EQ(url, resource.original_url); 778 EXPECT_EQ(url, resource.original_url);
778 resource.callback.Reset(); 779 resource.callback.Reset();
779 msg = process()->sink().GetFirstMessageMatching( 780 msg = process()->sink().GetFirstMessageMatching(
780 SafeBrowsingMsg_StartPhishingDetection::ID); 781 SafeBrowsingMsg_StartPhishingDetection::ID);
781 ASSERT_FALSE(msg); 782 ASSERT_FALSE(msg);
782 } 783 }
783 784
784 } // namespace safe_browsing 785 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698