| 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 #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 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/test/base/test_tab_strip_model_observer.h" | 25 #include "chrome/test/base/test_tab_strip_model_observer.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/browser/web_ui_controller.h" | 29 #include "content/public/browser/web_ui_controller.h" |
| 30 #include "content/public/browser/web_ui_message_handler.h" | 30 #include "content/public/browser/web_ui_message_handler.h" |
| 31 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gtest/include/gtest/gtest-spi.h" | 33 #include "testing/gtest/include/gtest/gtest-spi.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 35 #include "ui/base/resource/resource_handle.h" |
| 35 | 36 |
| 36 using content::NavigationController; | 37 using content::NavigationController; |
| 37 using content::RenderViewHost; | 38 using content::RenderViewHost; |
| 38 using content::WebContents; | 39 using content::WebContents; |
| 39 using content::WebUIController; | 40 using content::WebUIController; |
| 40 using content::WebUIMessageHandler; | 41 using content::WebUIMessageHandler; |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 const FilePath::CharType kMockJS[] = FILE_PATH_LITERAL("mock4js.js"); | 45 const FilePath::CharType kMockJS[] = FILE_PATH_LITERAL("mock4js.js"); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 GURL(kDummyURL).host(), mock_provider_.Pointer()); | 314 GURL(kDummyURL).host(), mock_provider_.Pointer()); |
| 314 | 315 |
| 315 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_)); | 316 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_)); |
| 316 test_data_directory_ = test_data_directory_.Append(kWebUITestFolder); | 317 test_data_directory_ = test_data_directory_.Append(kWebUITestFolder); |
| 317 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, | 318 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, |
| 318 &gen_test_data_directory_)); | 319 &gen_test_data_directory_)); |
| 319 | 320 |
| 320 // TODO(dtseng): should this be part of every BrowserTest or just WebUI test. | 321 // TODO(dtseng): should this be part of every BrowserTest or just WebUI test. |
| 321 FilePath resources_pack_path; | 322 FilePath resources_pack_path; |
| 322 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 323 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 323 ResourceBundle::GetSharedInstance().AddDataPack(resources_pack_path); | 324 ResourceBundle::GetSharedInstance().AddDataPack( |
| 325 resources_pack_path, ui::ResourceHandle::kScaleFactor100x); |
| 324 | 326 |
| 325 FilePath mockPath; | 327 FilePath mockPath; |
| 326 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &mockPath)); | 328 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &mockPath)); |
| 327 mockPath = mockPath.AppendASCII("chrome"); | 329 mockPath = mockPath.AppendASCII("chrome"); |
| 328 mockPath = mockPath.AppendASCII("third_party"); | 330 mockPath = mockPath.AppendASCII("third_party"); |
| 329 mockPath = mockPath.AppendASCII("mock4js"); | 331 mockPath = mockPath.AppendASCII("mock4js"); |
| 330 mockPath = mockPath.Append(kMockJS); | 332 mockPath = mockPath.Append(kMockJS); |
| 331 AddLibrary(mockPath); | 333 AddLibrary(mockPath); |
| 332 AddLibrary(FilePath(kWebUILibraryJS)); | 334 AddLibrary(FilePath(kWebUILibraryJS)); |
| 333 } | 335 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 // testDone directly and expect pass result. | 689 // testDone directly and expect pass result. |
| 688 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 690 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
| 689 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 691 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
| 690 } | 692 } |
| 691 | 693 |
| 692 // Test that calling testDone during RunJavascriptTest still completes when | 694 // Test that calling testDone during RunJavascriptTest still completes when |
| 693 // waiting for async result. | 695 // waiting for async result. |
| 694 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 696 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
| 695 ASSERT_TRUE(RunJavascriptTest("testDone")); | 697 ASSERT_TRUE(RunJavascriptTest("testDone")); |
| 696 } | 698 } |
| OLD | NEW |