OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/app/chrome_dll_resource.h" | 5 #include "chrome/app/chrome_dll_resource.h" |
6 #include "chrome/browser/view_ids.h" | 6 #include "chrome/browser/view_ids.h" |
7 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" | 7 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" |
8 #include "chrome/test/automation/browser_proxy.h" | 8 #include "chrome/test/automation/browser_proxy.h" |
9 #include "chrome/test/automation/tab_proxy.h" | 9 #include "chrome/test/automation/tab_proxy.h" |
10 #include "chrome/test/automation/window_proxy.h" | 10 #include "chrome/test/automation/window_proxy.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 if (!browser->WaitForTabToBecomeActive(new_tab_index, action_timeout_ms())) { | 235 if (!browser->WaitForTabToBecomeActive(new_tab_index, action_timeout_ms())) { |
236 LogWarningMessage("failed_to_reindex_tab"); | 236 LogWarningMessage("failed_to_reindex_tab"); |
237 return false; | 237 return false; |
238 } | 238 } |
239 | 239 |
240 return true; | 240 return true; |
241 } | 241 } |
242 #endif | 242 #endif |
243 | 243 |
244 bool AutomatedUITestBase::FindInPage() { | |
245 if (!RunCommandAsync(IDC_FIND)) | |
246 return false; | |
247 | |
248 return WaitForFindWindowVisibilityChange(active_browser(), true); | |
249 } | |
250 | |
251 bool AutomatedUITestBase::ForwardButton() { | 244 bool AutomatedUITestBase::ForwardButton() { |
252 return RunCommand(IDC_FORWARD); | 245 return RunCommand(IDC_FORWARD); |
253 } | 246 } |
254 | 247 |
255 bool AutomatedUITestBase::GoOffTheRecord() { | 248 bool AutomatedUITestBase::GoOffTheRecord() { |
256 return RunCommand(IDC_NEW_INCOGNITO_WINDOW); | 249 return RunCommand(IDC_NEW_INCOGNITO_WINDOW); |
257 } | 250 } |
258 | 251 |
259 bool AutomatedUITestBase::Home() { | |
260 return RunCommand(IDC_HOME); | |
261 } | |
262 | |
263 bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow( | 252 bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow( |
264 scoped_refptr<BrowserProxy>* previous_browser) { | 253 scoped_refptr<BrowserProxy>* previous_browser) { |
265 if (!automation()->OpenNewBrowserWindow(true /* SW_SHOWNORMAL */)) { | 254 if (!automation()->OpenNewBrowserWindow(true /* SW_SHOWNORMAL */)) { |
266 LogWarningMessage("failed_to_open_new_browser_window"); | 255 LogWarningMessage("failed_to_open_new_browser_window"); |
267 return false; | 256 return false; |
268 } | 257 } |
269 int num_browser_windows; | 258 int num_browser_windows; |
270 if (!automation()->GetBrowserWindowCount(&num_browser_windows)) { | 259 if (!automation()->GetBrowserWindowCount(&num_browser_windows)) { |
271 LogErrorMessage("failed_to_get_browser_window_count"); | 260 LogErrorMessage("failed_to_get_browser_window_count"); |
272 return false; | 261 return false; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 310 } |
322 | 311 |
323 bool AutomatedUITestBase::ReloadPage() { | 312 bool AutomatedUITestBase::ReloadPage() { |
324 return RunCommand(IDC_RELOAD); | 313 return RunCommand(IDC_RELOAD); |
325 } | 314 } |
326 | 315 |
327 bool AutomatedUITestBase::RestoreTab() { | 316 bool AutomatedUITestBase::RestoreTab() { |
328 return RunCommand(IDC_RESTORE_TAB); | 317 return RunCommand(IDC_RESTORE_TAB); |
329 } | 318 } |
330 | 319 |
331 bool AutomatedUITestBase::SelectNextTab() { | |
332 return RunCommand(IDC_SELECT_NEXT_TAB); | |
333 } | |
334 | |
335 bool AutomatedUITestBase::SelectPreviousTab() { | |
336 return RunCommand(IDC_SELECT_PREVIOUS_TAB); | |
337 } | |
338 | |
339 bool AutomatedUITestBase::ShowBookmarkBar() { | |
340 bool is_visible; | |
341 bool is_animating; | |
342 if (!active_browser()->GetBookmarkBarVisibility(&is_visible, | |
343 &is_animating)) { | |
344 return false; | |
345 } | |
346 | |
347 if (is_visible) { | |
348 // If the bar is visible, then issuing the command again will toggle it. | |
349 return true; | |
350 } | |
351 | |
352 if (!RunCommandAsync(IDC_SHOW_BOOKMARK_BAR)) | |
353 return false; | |
354 | |
355 return WaitForBookmarkBarVisibilityChange(active_browser(), true); | |
356 } | |
357 | |
358 bool AutomatedUITestBase::ShowDownloads() { | |
359 return RunCommand(IDC_SHOW_DOWNLOADS); | |
360 } | |
361 | |
362 bool AutomatedUITestBase::ShowHistory() { | |
363 return RunCommand(IDC_SHOW_HISTORY); | |
364 } | |
365 | |
366 bool AutomatedUITestBase::RunCommandAsync(int browser_command) { | 320 bool AutomatedUITestBase::RunCommandAsync(int browser_command) { |
367 BrowserProxy* browser = active_browser(); | 321 BrowserProxy* browser = active_browser(); |
368 if (NULL == browser) { | 322 if (NULL == browser) { |
369 LogErrorMessage("browser_window_not_found"); | 323 LogErrorMessage("browser_window_not_found"); |
370 return false; | 324 return false; |
371 } | 325 } |
372 | 326 |
373 if (!browser->RunCommandAsync(browser_command)) { | 327 if (!browser->RunCommandAsync(browser_command)) { |
374 LogWarningMessage("failure_running_browser_command"); | 328 LogWarningMessage("failure_running_browser_command"); |
375 return false; | 329 return false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 BrowserProxy* browser) { | 364 BrowserProxy* browser) { |
411 bool did_timeout; | 365 bool did_timeout; |
412 if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), | 366 if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), |
413 &did_timeout)) { | 367 &did_timeout)) { |
414 LogWarningMessage("failed_to_bring_window_to_front"); | 368 LogWarningMessage("failed_to_bring_window_to_front"); |
415 return NULL; | 369 return NULL; |
416 } | 370 } |
417 | 371 |
418 return browser->GetWindow(); | 372 return browser->GetWindow(); |
419 } | 373 } |
OLD | NEW |