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

Side by Side Diff: chrome_frame/test/test_mock_with_web_server.h

Issue 2822016: [chrome_frame] Refactor/merge IE no interference tests with other mock event ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | « chrome_frame/test/simulate_input.cc ('k') | chrome_frame/test/test_mock_with_web_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #ifndef CHROME_FRAME_TEST_MOCK_WITH_WEB_SERVER_H_
5 #define CHROME_FRAME_TEST_MOCK_WITH_WEB_SERVER_H_
6
7 #include <windows.h>
8
9 #include "gmock/gmock.h"
10 #include "chrome_frame/chrome_frame_automation.h"
11 #include "chrome_frame/test/chrome_frame_test_utils.h"
12
13 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING
14 #include "testing/gmock_mutant.h"
15
16 namespace chrome_frame_test {
17
18 using ::testing::Expectation;
19 using ::testing::ExpectationSet;
20
21 // This class provides functionality to add expectations to IE full tab mode
22 // tests.
23 class MockWebBrowserEventSink : public chrome_frame_test::WebBrowserEventSink {
24 public:
25 // Needed to support PostTask.
26 static bool ImplementsThreadSafeReferenceCounting() {
27 return true;
28 }
29
30 MOCK_METHOD7_WITH_CALLTYPE(__stdcall, OnBeforeNavigate2,
31 void (IDispatch* dispatch, // NOLINT
32 VARIANT* url,
33 VARIANT* flags,
34 VARIANT* target_frame_name,
35 VARIANT* post_data,
36 VARIANT* headers,
37 VARIANT_BOOL* cancel));
38
39 MOCK_METHOD2_WITH_CALLTYPE(__stdcall, OnNavigateComplete2,
40 void (IDispatch* dispatch, // NOLINT
41 VARIANT* url));
42
43 MOCK_METHOD5_WITH_CALLTYPE(__stdcall, OnNewWindow3,
44 void (IDispatch** dispatch, // NOLINT
45 VARIANT_BOOL* cancel,
46 DWORD flags,
47 BSTR url_context,
48 BSTR url));
49
50 MOCK_METHOD2_WITH_CALLTYPE(__stdcall, OnNewWindow2,
51 void (IDispatch** dispatch, // NOLINT
52 VARIANT_BOOL* cancel));
53
54 MOCK_METHOD5_WITH_CALLTYPE(__stdcall, OnNavigateError,
55 void (IDispatch* dispatch, // NOLINT
56 VARIANT* url,
57 VARIANT* frame_name,
58 VARIANT* status_code,
59 VARIANT* cancel));
60
61 MOCK_METHOD2_WITH_CALLTYPE(__stdcall, OnFileDownload,
62 void (VARIANT_BOOL active_doc,
63 VARIANT_BOOL* cancel));
64
65 MOCK_METHOD0_WITH_CALLTYPE(__stdcall, OnQuit,
66 void ());
67
68 MOCK_METHOD1(OnLoad, void (const wchar_t* url)); // NOLINT
69 MOCK_METHOD1(OnLoadError, void (const wchar_t* url)); // NOLINT
70 MOCK_METHOD3(OnMessage, void (const wchar_t* message,
71 const wchar_t* origin,
72 const wchar_t* source)); // NOLINT
73 MOCK_METHOD2(OnNewBrowserWindow, void (IDispatch* dispatch, // NOLINT
74 const wchar_t* url));
75 MOCK_METHOD2(OnWindowDetected, void (HWND hwnd, // NOLINT
76 const std::string& caption));
77
78 // Test expectations for general navigations.
79 ExpectationSet ExpectNavigationCardinality(const std::wstring& url,
80 testing::Cardinality cardinality);
81 ExpectationSet ExpectNavigation(const std::wstring& url);
82 ExpectationSet ExpectNavigationAndSwitch(const std::wstring& url);
83 ExpectationSet ExpectNavigationAndSwitchSequence(const std::wstring& url);
84 ExpectationSet ExpectNewWindow(MockWebBrowserEventSink* new_window_mock);
85 ExpectationSet ExpectNavigationSequenceForAnchors(const std::wstring& url);
86
87 // Test expectations for navigations with an IE renderer.
88 // Expect one navigation to occur.
89 ExpectationSet ExpectNavigationInIE(const std::wstring& url);
90 // Expect a new window to be opened to |url|. Set |new_window_mock| as the new
91 // window.
92 ExpectationSet ExpectNewWindowWithIE(
93 const std::wstring& url, MockWebBrowserEventSink* new_window_mock);
94 };
95
96 ACTION_P(CloseBrowserMock, mock) {
97 mock->CloseWebBrowser();
98 }
99
100 ACTION_P(VerifyAddressBarUrl, mock) {
101 mock->ExpectAddressBarUrl(std::wstring(arg0));
102 }
103
104 ACTION_P4(DelaySendScanCode, loop, delay, c, mod) {
105 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
106 simulate_input::SendScanCode, c, mod), delay);
107 }
108
109 ACTION_P5(ValidateWindowSize, mock, left, top, width, height) {
110 long actual_left = 0;
111 long actual_top = 0;
112 long actual_width = 0;
113 long actual_height = 0;
114
115 mock->web_browser2()->get_Left(&actual_left);
116 mock->web_browser2()->get_Top(&actual_top);
117 mock->web_browser2()->get_Width(&actual_width);
118 mock->web_browser2()->get_Height(&actual_height);
119
120 EXPECT_EQ(actual_left, left);
121 EXPECT_EQ(actual_top, top);
122 EXPECT_EQ(actual_width, width);
123 EXPECT_EQ(actual_height, height);
124 }
125
126 ACTION_P4(DelaySendChar, loop, delay, c, mod) {
127 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
128 simulate_input::SendCharA, c, mod), delay);
129 }
130
131 ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) {
132 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock,
133 &MockWebBrowserEventSink::CloseWebBrowser), delay);
134 }
135
136 } // namespace chrome_frame_test
137
138 #endif // CHROME_FRAME_TEST_MOCK_WITH_WEB_SERVER_H_
139
OLDNEW
« no previous file with comments | « chrome_frame/test/simulate_input.cc ('k') | chrome_frame/test/test_mock_with_web_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698