OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Executes javascript to execute a given test case found in the current | 85 // Executes javascript to execute a given test case found in the current |
86 // page's script. If |wait_for_response| is true, this method will not | 86 // page's script. If |wait_for_response| is true, this method will not |
87 // return until the javascript has been executed. | 87 // return until the javascript has been executed. |
88 // Use with [ASSERT|EXPECT]_NO_FATAL_FAILURE. | 88 // Use with [ASSERT|EXPECT]_NO_FATAL_FAILURE. |
89 void RunTestCaseInJavaScript(int test_case_number, bool wait_for_response) { | 89 void RunTestCaseInJavaScript(int test_case_number, bool wait_for_response) { |
90 std::string script = base::StringPrintf("runTestCase(%d);", | 90 std::string script = base::StringPrintf("runTestCase(%d);", |
91 test_case_number); | 91 test_case_number); |
92 content::RenderViewHost* host = | 92 content::RenderViewHost* host = |
93 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); | 93 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); |
94 if (wait_for_response) { | 94 if (wait_for_response) { |
95 ASSERT_TRUE(content::ExecuteJavaScript( | 95 ASSERT_TRUE(content::ExecuteScript(host, script)); |
96 host, "", script)); | |
97 } else { | 96 } else { |
98 script += "window.domAutomationController.setAutomationId(0);" | 97 script += "window.domAutomationController.setAutomationId(0);" |
99 "window.domAutomationController.send(0);"; | 98 "window.domAutomationController.send(0);"; |
100 host->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(script)); | 99 host->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(script)); |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 // Returns the |AutomationTabHelper| for the first browser's first tab. | 103 // Returns the |AutomationTabHelper| for the first browser's first tab. |
105 AutomationTabHelper* tab_helper() { | 104 AutomationTabHelper* tab_helper() { |
106 return AutomationTabHelper::FromWebContents( | 105 return AutomationTabHelper::FromWebContents( |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 IN_PROC_BROWSER_TEST_F(AutomationTabHelperBrowserTest, | 206 IN_PROC_BROWSER_TEST_F(AutomationTabHelperBrowserTest, |
208 CrashedTabStopsLoading) { | 207 CrashedTabStopsLoading) { |
209 MockTabEventObserver mock_tab_observer(tab_helper()); | 208 MockTabEventObserver mock_tab_observer(tab_helper()); |
210 | 209 |
211 testing::InSequence expect_in_sequence; | 210 testing::InSequence expect_in_sequence; |
212 EXPECT_CALL(mock_tab_observer, OnFirstPendingLoad(_)); | 211 EXPECT_CALL(mock_tab_observer, OnFirstPendingLoad(_)); |
213 EXPECT_CALL(mock_tab_observer, OnNoMorePendingLoads(_)); | 212 EXPECT_CALL(mock_tab_observer, OnNoMorePendingLoads(_)); |
214 | 213 |
215 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); | 214 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); |
216 } | 215 } |
OLD | NEW |