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

Side by Side Diff: chrome_frame/test/automation_client_mock.cc

Issue 890005: Add a command line flag to disable infobars. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome_frame/delete_chrome_history.cc ('k') | chrome_frame/test/chrome_frame_automation_mock.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome_frame/test/automation_client_mock.h" 4 #include "chrome_frame/test/automation_client_mock.h"
5 5
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "chrome_frame/test/chrome_frame_test_utils.h" 8 #include "chrome_frame/test/chrome_frame_test_utils.h"
9 9
10 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING 10 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 const FilePath profile_path( 94 const FilePath profile_path(
95 chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter")); 95 chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
96 96
97 scoped_refptr<ChromeFrameAutomationClient> client; 97 scoped_refptr<ChromeFrameAutomationClient> client;
98 client = new ChromeFrameAutomationClient(); 98 client = new ChromeFrameAutomationClient();
99 99
100 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(AUTOMATION_TIMEOUT, _)) 100 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(AUTOMATION_TIMEOUT, _))
101 .Times(1) 101 .Times(1)
102 .WillOnce(QUIT_LOOP(loop)); 102 .WillOnce(QUIT_LOOP(loop));
103 103
104 EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"", 104 ChromeFrameLaunchParams clp = {
105 false)); 105 timeout,
106 GURL(),
107 GURL(),
108 profile_path,
109 profile_path.BaseName().value(),
110 L"",
111 false,
112 false,
113 false
114 };
115 EXPECT_TRUE(client->Initialize(&cfd, clp));
106 loop.RunFor(10); 116 loop.RunFor(10);
107 client->Uninitialize(); 117 client->Uninitialize();
108 } 118 }
109 119
110 // This test may fail if Chrome take more that 10 seconds (timeout var) to 120 // This test may fail if Chrome take more that 10 seconds (timeout var) to
111 // launch. In this case GMock shall print something like "unexpected call to 121 // launch. In this case GMock shall print something like "unexpected call to
112 // OnAutomationServerLaunchFailed". I'm yet to find out how to specify 122 // OnAutomationServerLaunchFailed". I'm yet to find out how to specify
113 // that this is an unexpected call, and still to execute and action. 123 // that this is an unexpected call, and still to execute and action.
114 TEST(CFACWithChrome, CreateNotSoFast) { 124 TEST(CFACWithChrome, CreateNotSoFast) {
115 MockCFDelegate cfd; 125 MockCFDelegate cfd;
116 chrome_frame_test::TimedMsgLoop loop; 126 chrome_frame_test::TimedMsgLoop loop;
117 const FilePath profile_path( 127 const FilePath profile_path(
118 chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter")); 128 chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
119 int timeout = 10000; 129 int timeout = 10000;
120 130
121 scoped_refptr<ChromeFrameAutomationClient> client; 131 scoped_refptr<ChromeFrameAutomationClient> client;
122 client = new ChromeFrameAutomationClient; 132 client = new ChromeFrameAutomationClient;
123 133
124 EXPECT_CALL(cfd, OnAutomationServerReady()) 134 EXPECT_CALL(cfd, OnAutomationServerReady())
125 .Times(1) 135 .Times(1)
126 .WillOnce(QUIT_LOOP(loop)); 136 .WillOnce(QUIT_LOOP(loop));
127 137
128 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(_, _)) 138 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(_, _))
129 .Times(0); 139 .Times(0);
130 140
131 EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"", 141 ChromeFrameLaunchParams clp = {
132 false)); 142 timeout,
143 GURL(),
144 GURL(),
145 profile_path,
146 profile_path.BaseName().value(),
147 L"",
148 false,
149 false,
150 false
151 };
152 EXPECT_TRUE(client->Initialize(&cfd, clp));
133 153
134 loop.RunFor(11); 154 loop.RunFor(11);
135 client->Uninitialize(); 155 client->Uninitialize();
136 client = NULL; 156 client = NULL;
137 } 157 }
138 158
139 TEST(CFACWithChrome, NavigateOk) { 159 TEST(CFACWithChrome, NavigateOk) {
140 MockCFDelegate cfd; 160 MockCFDelegate cfd;
141 chrome_frame_test::TimedMsgLoop loop; 161 chrome_frame_test::TimedMsgLoop loop;
142 const std::string url = "about:version"; 162 const std::string url = "about:version";
(...skipping 20 matching lines...) Expand all
163 EXPECT_CALL(cfd, OnDidNavigate(_, EqNavigationInfoUrl(GURL()))) 183 EXPECT_CALL(cfd, OnDidNavigate(_, EqNavigationInfoUrl(GURL())))
164 .Times(1); 184 .Times(1);
165 185
166 EXPECT_CALL(cfd, OnUpdateTargetUrl(_, _)).Times(1); 186 EXPECT_CALL(cfd, OnUpdateTargetUrl(_, _)).Times(1);
167 187
168 EXPECT_CALL(cfd, OnLoad(_, _)) 188 EXPECT_CALL(cfd, OnLoad(_, _))
169 .Times(1) 189 .Times(1)
170 .WillOnce(QUIT_LOOP(loop)); 190 .WillOnce(QUIT_LOOP(loop));
171 } 191 }
172 192
173 EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"", 193 ChromeFrameLaunchParams clp = {
174 false)); 194 timeout,
195 GURL(),
196 GURL(),
197 profile_path,
198 profile_path.BaseName().value(),
199 L"",
200 false,
201 false,
202 false
203 };
204 EXPECT_TRUE(client->Initialize(&cfd, clp));
175 loop.RunFor(10); 205 loop.RunFor(10);
176 client->Uninitialize(); 206 client->Uninitialize();
177 client = NULL; 207 client = NULL;
178 } 208 }
179 209
180 TEST(CFACWithChrome, NavigateFailed) { 210 TEST(CFACWithChrome, NavigateFailed) {
181 MockCFDelegate cfd; 211 MockCFDelegate cfd;
182 chrome_frame_test::TimedMsgLoop loop; 212 chrome_frame_test::TimedMsgLoop loop;
183 const FilePath profile_path( 213 const FilePath profile_path(
184 chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter")); 214 chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
(...skipping 19 matching lines...) Expand all
204 .WillRepeatedly(testing::WithArgs<1>(testing::Invoke(CreateFunctor(&cfd, 234 .WillRepeatedly(testing::WithArgs<1>(testing::Invoke(CreateFunctor(&cfd,
205 &MockCFDelegate::Reply, connection_failed)))); 235 &MockCFDelegate::Reply, connection_failed))));
206 236
207 EXPECT_CALL(cfd, OnUpdateTargetUrl(_, _)).Times(testing::AnyNumber()); 237 EXPECT_CALL(cfd, OnUpdateTargetUrl(_, _)).Times(testing::AnyNumber());
208 EXPECT_CALL(cfd, OnLoad(_, _)).Times(testing::AtMost(1)); 238 EXPECT_CALL(cfd, OnLoad(_, _)).Times(testing::AtMost(1));
209 239
210 EXPECT_CALL(cfd, OnNavigationFailed(_, _, GURL(url))) 240 EXPECT_CALL(cfd, OnNavigationFailed(_, _, GURL(url)))
211 .Times(1) 241 .Times(1)
212 .WillOnce(QUIT_LOOP_SOON(loop, 2)); 242 .WillOnce(QUIT_LOOP_SOON(loop, 2));
213 243
214 EXPECT_TRUE(client->Initialize(&cfd, 10000, false, profile_path, L"", 244 ChromeFrameLaunchParams clp = {
215 false)); 245 10000,
246 GURL(),
247 GURL(),
248 profile_path,
249 profile_path.BaseName().value(),
250 L"",
251 false,
252 false,
253 false
254 };
255 EXPECT_TRUE(client->Initialize(&cfd, clp));
216 256
217 loop.RunFor(10); 257 loop.RunFor(10);
218 client->Uninitialize(); 258 client->Uninitialize();
219 client = NULL; 259 client = NULL;
220 } 260 }
221 261
222 TEST_F(CFACMockTest, MockedCreateTabOk) { 262 TEST_F(CFACMockTest, MockedCreateTabOk) {
223 int timeout = 500; 263 int timeout = 500;
224 CreateTab(); 264 CreateTab();
225 SetAutomationServerOk(); 265 SetAutomationServerOk();
(...skipping 12 matching lines...) Expand all
238 278
239 EXPECT_CALL(proxy_, CreateTabProxy(testing::Eq(tab_handle_))) 279 EXPECT_CALL(proxy_, CreateTabProxy(testing::Eq(tab_handle_)))
240 .WillOnce(testing::Return(tab_)); 280 .WillOnce(testing::Return(tab_));
241 281
242 EXPECT_CALL(cfd_, OnAutomationServerReady()) 282 EXPECT_CALL(cfd_, OnAutomationServerReady())
243 .WillOnce(QUIT_LOOP(loop_)); 283 .WillOnce(QUIT_LOOP(loop_));
244 284
245 EXPECT_CALL(proxy_, CancelAsync(_)).Times(testing::AnyNumber()); 285 EXPECT_CALL(proxy_, CancelAsync(_)).Times(testing::AnyNumber());
246 286
247 // Here we go! 287 // Here we go!
248 EXPECT_TRUE(client_->Initialize(&cfd_, timeout, false, profile_path_, L"", 288 ChromeFrameLaunchParams clp = {
249 false)); 289 timeout,
290 GURL(),
291 GURL(),
292 profile_path_,
293 profile_path_.BaseName().value(),
294 L"",
295 false,
296 false,
297 false
298 };
299 EXPECT_TRUE(client_->Initialize(&cfd_, clp));
250 loop_.RunFor(10); 300 loop_.RunFor(10);
251 client_->Uninitialize(); 301 client_->Uninitialize();
252 } 302 }
253 303
254 TEST_F(CFACMockTest, MockedCreateTabFailed) { 304 TEST_F(CFACMockTest, MockedCreateTabFailed) {
255 HWND null_wnd = NULL; 305 HWND null_wnd = NULL;
256 SetAutomationServerOk(); 306 SetAutomationServerOk();
257 307
258 EXPECT_CALL(proxy_, server_version()).Times(testing::AnyNumber()) 308 EXPECT_CALL(proxy_, server_version()).Times(testing::AnyNumber())
259 .WillRepeatedly(testing::Return("")); 309 .WillRepeatedly(testing::Return(""));
260 310
261 EXPECT_CALL(proxy_, SendAsAsync(testing::Property(&IPC::SyncMessage::type, 311 EXPECT_CALL(proxy_, SendAsAsync(testing::Property(&IPC::SyncMessage::type,
262 AutomationMsg_CreateExternalTab__ID), 312 AutomationMsg_CreateExternalTab__ID),
263 testing::NotNull(), _)) 313 testing::NotNull(), _))
264 .Times(1) 314 .Times(1)
265 .WillOnce(HandleCreateTab(tab_handle_, null_wnd, null_wnd)); 315 .WillOnce(HandleCreateTab(tab_handle_, null_wnd, null_wnd));
266 316
267 EXPECT_CALL(proxy_, CreateTabProxy(_)).Times(0); 317 EXPECT_CALL(proxy_, CreateTabProxy(_)).Times(0);
268 318
269 EXPECT_CALL(proxy_, CancelAsync(_)).Times(testing::AnyNumber()); 319 EXPECT_CALL(proxy_, CancelAsync(_)).Times(testing::AnyNumber());
270 320
271 Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED); 321 Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED);
272 322
273 // Here we go! 323 // Here we go!
274 EXPECT_TRUE(client_->Initialize(&cfd_, timeout_, false, profile_path_, L"", 324 ChromeFrameLaunchParams clp = {
275 false)); 325 timeout_,
326 GURL(),
327 GURL(),
328 profile_path_,
329 profile_path_.BaseName().value(),
330 L"",
331 false,
332 false,
333 false
334 };
335 EXPECT_TRUE(client_->Initialize(&cfd_, clp));
276 loop_.RunFor(4); 336 loop_.RunFor(4);
277 client_->Uninitialize(); 337 client_->Uninitialize();
278 } 338 }
279 339
OLDNEW
« no previous file with comments | « chrome_frame/delete_chrome_history.cc ('k') | chrome_frame/test/chrome_frame_automation_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698