OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/ui/webui/web_ui_browsertest.h" | 4 #include "chrome/browser/ui/webui/web_ui_browsertest.h" |
5 | 5 |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "chrome/test/base/test_tab_strip_model_observer.h" | 23 #include "chrome/test/base/test_tab_strip_model_observer.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
25 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_ui_message_handler.h" | 27 #include "content/public/browser/web_ui_message_handler.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest-spi.h" | 29 #include "testing/gtest/include/gtest/gtest-spi.h" |
30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
31 | 31 |
| 32 using content::NavigationController; |
32 using content::WebContents; | 33 using content::WebContents; |
33 using content::WebUIMessageHandler; | 34 using content::WebUIMessageHandler; |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 const FilePath::CharType kMockJS[] = FILE_PATH_LITERAL("mock4js.js"); | 38 const FilePath::CharType kMockJS[] = FILE_PATH_LITERAL("mock4js.js"); |
38 const FilePath::CharType kWebUILibraryJS[] = FILE_PATH_LITERAL("test_api.js"); | 39 const FilePath::CharType kWebUILibraryJS[] = FILE_PATH_LITERAL("test_api.js"); |
39 const FilePath::CharType kWebUITestFolder[] = FILE_PATH_LITERAL("webui"); | 40 const FilePath::CharType kWebUITestFolder[] = FILE_PATH_LITERAL("webui"); |
40 base::LazyInstance<std::vector<std::string> > error_messages_ = | 41 base::LazyInstance<std::vector<std::string> > error_messages_ = |
41 LAZY_INSTANCE_INITIALIZER; | 42 LAZY_INSTANCE_INITIALIZER; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 ConstValueVector args; | 176 ConstValueVector args; |
176 args.push_back(Value::CreateStringValue(preload_test_fixture)); | 177 args.push_back(Value::CreateStringValue(preload_test_fixture)); |
177 args.push_back(Value::CreateStringValue(preload_test_name)); | 178 args.push_back(Value::CreateStringValue(preload_test_name)); |
178 RunJavascriptUsingHandler( | 179 RunJavascriptUsingHandler( |
179 "preloadJavascriptLibraries", args, false, false, preload_host); | 180 "preloadJavascriptLibraries", args, false, false, preload_host); |
180 libraries_preloaded_ = true; | 181 libraries_preloaded_ = true; |
181 } | 182 } |
182 | 183 |
183 void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) { | 184 void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) { |
184 TestNavigationObserver navigation_observer( | 185 TestNavigationObserver navigation_observer( |
185 content::Source<content::NavigationController>( | 186 content::Source<NavigationController>( |
186 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 187 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
187 GetController()), | 188 GetController()), |
188 this, 1); | 189 this, 1); |
189 browser::NavigateParams params( | 190 browser::NavigateParams params( |
190 browser(), GURL(browse_to), content::PAGE_TRANSITION_TYPED); | 191 browser(), GURL(browse_to), content::PAGE_TRANSITION_TYPED); |
191 params.disposition = CURRENT_TAB; | 192 params.disposition = CURRENT_TAB; |
192 browser::Navigate(¶ms); | 193 browser::Navigate(¶ms); |
193 navigation_observer.WaitForObservation( | 194 navigation_observer.WaitForObservation( |
194 base::Bind(&ui_test_utils::RunMessageLoop), | 195 base::Bind(&ui_test_utils::RunMessageLoop), |
195 base::Bind(&MessageLoop::Quit, | 196 base::Bind(&MessageLoop::Quit, |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 // testDone directly and expect pass result. | 643 // testDone directly and expect pass result. |
643 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 644 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
644 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 645 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
645 } | 646 } |
646 | 647 |
647 // Test that calling testDone during RunJavascriptTest still completes when | 648 // Test that calling testDone during RunJavascriptTest still completes when |
648 // waiting for async result. | 649 // waiting for async result. |
649 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 650 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
650 ASSERT_TRUE(RunJavascriptTest("testDone")); | 651 ASSERT_TRUE(RunJavascriptTest("testDone")); |
651 } | 652 } |
OLD | NEW |