| 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 "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "chrome/app/chrome_dll_resource.h" | 6 #include "chrome/app/chrome_dll_resource.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool AutomatedUITestBase::NewTab() { | 57 bool AutomatedUITestBase::NewTab() { |
| 58 // Apply accelerator and wait for a new tab to open, if either | 58 // Apply accelerator and wait for a new tab to open, if either |
| 59 // fails, return false. Apply Accelerator takes care of logging its failure. | 59 // fails, return false. Apply Accelerator takes care of logging its failure. |
| 60 return RunCommand(IDC_NEW_TAB); | 60 return RunCommand(IDC_NEW_TAB); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool AutomatedUITestBase::RunCommandAsync(int browser_command) { | 63 bool AutomatedUITestBase::RunCommandAsync(int browser_command) { |
| 64 scoped_ptr<BrowserProxy> last_browser; | |
| 65 BrowserProxy* browser = active_browser(); | 64 BrowserProxy* browser = active_browser(); |
| 66 if (NULL == browser) { | 65 if (NULL == browser) { |
| 67 last_browser.reset(automation()->GetLastActiveBrowserWindow()); | |
| 68 browser = last_browser.get(); | |
| 69 } | |
| 70 if (NULL == browser) { | |
| 71 LogErrorMessage("browser_window_not_found"); | 66 LogErrorMessage("browser_window_not_found"); |
| 72 return false; | 67 return false; |
| 73 } | 68 } |
| 74 | 69 |
| 75 if (!browser->RunCommandAsync(browser_command)) { | 70 if (!browser->RunCommandAsync(browser_command)) { |
| 76 LogWarningMessage("failure_running_browser_command"); | 71 LogWarningMessage("failure_running_browser_command"); |
| 77 return false; | 72 return false; |
| 78 } | 73 } |
| 79 return true; | 74 return true; |
| 80 } | 75 } |
| 81 | 76 |
| 82 bool AutomatedUITestBase::RunCommand(int browser_command) { | 77 bool AutomatedUITestBase::RunCommand(int browser_command) { |
| 83 scoped_ptr<BrowserProxy> last_browser; | |
| 84 BrowserProxy* browser = active_browser(); | 78 BrowserProxy* browser = active_browser(); |
| 85 if (NULL == browser) { | 79 if (NULL == browser) { |
| 86 last_browser.reset(automation()->GetLastActiveBrowserWindow()); | |
| 87 browser = last_browser.get(); | |
| 88 } | |
| 89 if (NULL == browser) { | |
| 90 LogErrorMessage("browser_window_not_found"); | 80 LogErrorMessage("browser_window_not_found"); |
| 91 return false; | 81 return false; |
| 92 } | 82 } |
| 93 | 83 |
| 94 if (!browser->RunCommand(browser_command)) { | 84 if (!browser->RunCommand(browser_command)) { |
| 95 LogWarningMessage("failure_running_browser_command"); | 85 LogWarningMessage("failure_running_browser_command"); |
| 96 return false; | 86 return false; |
| 97 } | 87 } |
| 98 return true; | 88 return true; |
| 99 } | 89 } |
| OLD | NEW |