| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/base/web_ui_browser_test.h" | 5 #include "chrome/test/base/web_ui_browser_test.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/ui/webui/web_ui_test_handler.h" | 25 #include "chrome/browser/ui/webui/web_ui_test_handler.h" |
| 26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" | 28 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" |
| 29 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
| 30 #include "content/public/browser/url_data_source.h" | 30 #include "content/public/browser/url_data_source.h" |
| 31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 32 #include "content/public/browser/web_contents_observer.h" | 32 #include "content/public/browser/web_contents_observer.h" |
| 33 #include "content/public/browser/web_ui_controller.h" | 33 #include "content/public/browser/web_ui_controller.h" |
| 34 #include "content/public/browser/web_ui_message_handler.h" | 34 #include "content/public/browser/web_ui_message_handler.h" |
| 35 #include "content/public/common/url_constants.h" |
| 35 #include "content/public/test/browser_test_utils.h" | 36 #include "content/public/test/browser_test_utils.h" |
| 36 #include "content/public/test/test_navigation_observer.h" | 37 #include "content/public/test/test_navigation_observer.h" |
| 37 #include "net/base/filename_util.h" | 38 #include "net/base/filename_util.h" |
| 38 #include "ui/base/resource/resource_handle.h" | 39 #include "ui/base/resource/resource_handle.h" |
| 39 | 40 |
| 40 #if defined(ENABLE_PRINT_PREVIEW) | 41 #if defined(ENABLE_PRINT_PREVIEW) |
| 41 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 42 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 using content::RenderViewHost; | 45 using content::RenderViewHost; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 378 |
| 378 content::WebUIControllerFactory::UnregisterFactoryForTesting( | 379 content::WebUIControllerFactory::UnregisterFactoryForTesting( |
| 379 ChromeWebUIControllerFactory::GetInstance()); | 380 ChromeWebUIControllerFactory::GetInstance()); |
| 380 | 381 |
| 381 test_factory_.reset(new TestChromeWebUIControllerFactory); | 382 test_factory_.reset(new TestChromeWebUIControllerFactory); |
| 382 | 383 |
| 383 content::WebUIControllerFactory::RegisterFactory(test_factory_.get()); | 384 content::WebUIControllerFactory::RegisterFactory(test_factory_.get()); |
| 384 | 385 |
| 385 test_factory_->AddFactoryOverride(GURL(kDummyURL).host(), | 386 test_factory_->AddFactoryOverride(GURL(kDummyURL).host(), |
| 386 mock_provider_.Pointer()); | 387 mock_provider_.Pointer()); |
| 388 test_factory_->AddFactoryOverride(content::kChromeUIResourcesHost, |
| 389 mock_provider_.Pointer()); |
| 387 } | 390 } |
| 388 | 391 |
| 389 void WebUIBrowserTest::TearDownOnMainThread() { | 392 void WebUIBrowserTest::TearDownOnMainThread() { |
| 390 logging::SetLogMessageHandler(NULL); | 393 logging::SetLogMessageHandler(NULL); |
| 391 | 394 |
| 392 test_factory_->RemoveFactoryOverride(GURL(kDummyURL).host()); | 395 test_factory_->RemoveFactoryOverride(GURL(kDummyURL).host()); |
| 393 content::WebUIControllerFactory::UnregisterFactoryForTesting( | 396 content::WebUIControllerFactory::UnregisterFactoryForTesting( |
| 394 test_factory_.get()); | 397 test_factory_.get()); |
| 395 | 398 |
| 396 // This is needed to avoid a debug assert after the test completes, see stack | 399 // This is needed to avoid a debug assert after the test completes, see stack |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 } | 483 } |
| 481 | 484 |
| 482 GURL WebUIBrowserTest::WebUITestDataPathToURL( | 485 GURL WebUIBrowserTest::WebUITestDataPathToURL( |
| 483 const base::FilePath::StringType& path) { | 486 const base::FilePath::StringType& path) { |
| 484 base::FilePath dir_test_data; | 487 base::FilePath dir_test_data; |
| 485 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); | 488 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); |
| 486 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); | 489 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); |
| 487 EXPECT_TRUE(base::PathExists(test_path)); | 490 EXPECT_TRUE(base::PathExists(test_path)); |
| 488 return net::FilePathToFileURL(test_path); | 491 return net::FilePathToFileURL(test_path); |
| 489 } | 492 } |
| OLD | NEW |