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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 }; | 365 }; |
366 | 366 |
367 base::LazyInstance<MockWebUIProvider> mock_provider_ = | 367 base::LazyInstance<MockWebUIProvider> mock_provider_ = |
368 LAZY_INSTANCE_INITIALIZER; | 368 LAZY_INSTANCE_INITIALIZER; |
369 | 369 |
370 } // namespace | 370 } // namespace |
371 | 371 |
372 void WebUIBrowserTest::SetUpOnMainThread() { | 372 void WebUIBrowserTest::SetUpOnMainThread() { |
373 JavaScriptBrowserTest::SetUpOnMainThread(); | 373 JavaScriptBrowserTest::SetUpOnMainThread(); |
374 | 374 |
375 logging::SetLogMessageHandler(&LogHandler); | 375 logging::PushLogMessageHandler(&LogHandler); |
376 | 376 |
377 AddLibrary(base::FilePath(kA11yAuditLibraryJSPath)); | 377 AddLibrary(base::FilePath(kA11yAuditLibraryJSPath)); |
378 | 378 |
379 content::WebUIControllerFactory::UnregisterFactoryForTesting( | 379 content::WebUIControllerFactory::UnregisterFactoryForTesting( |
380 ChromeWebUIControllerFactory::GetInstance()); | 380 ChromeWebUIControllerFactory::GetInstance()); |
381 | 381 |
382 test_factory_.reset(new TestChromeWebUIControllerFactory); | 382 test_factory_.reset(new TestChromeWebUIControllerFactory); |
383 | 383 |
384 content::WebUIControllerFactory::RegisterFactory(test_factory_.get()); | 384 content::WebUIControllerFactory::RegisterFactory(test_factory_.get()); |
385 | 385 |
386 test_factory_->AddFactoryOverride(GURL(kDummyURL).host(), | 386 test_factory_->AddFactoryOverride(GURL(kDummyURL).host(), |
387 mock_provider_.Pointer()); | 387 mock_provider_.Pointer()); |
388 test_factory_->AddFactoryOverride(content::kChromeUIResourcesHost, | 388 test_factory_->AddFactoryOverride(content::kChromeUIResourcesHost, |
389 mock_provider_.Pointer()); | 389 mock_provider_.Pointer()); |
390 } | 390 } |
391 | 391 |
392 void WebUIBrowserTest::TearDownOnMainThread() { | 392 void WebUIBrowserTest::TearDownOnMainThread() { |
393 logging::SetLogMessageHandler(NULL); | 393 logging::PopLogMessageHandler(); |
394 | 394 |
395 test_factory_->RemoveFactoryOverride(GURL(kDummyURL).host()); | 395 test_factory_->RemoveFactoryOverride(GURL(kDummyURL).host()); |
396 content::WebUIControllerFactory::UnregisterFactoryForTesting( | 396 content::WebUIControllerFactory::UnregisterFactoryForTesting( |
397 test_factory_.get()); | 397 test_factory_.get()); |
398 | 398 |
399 // 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 |
400 // trace in http://crrev.com/179347 | 400 // trace in http://crrev.com/179347 |
401 content::WebUIControllerFactory::RegisterFactory( | 401 content::WebUIControllerFactory::RegisterFactory( |
402 ChromeWebUIControllerFactory::GetInstance()); | 402 ChromeWebUIControllerFactory::GetInstance()); |
403 | 403 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 483 } |
484 | 484 |
485 GURL WebUIBrowserTest::WebUITestDataPathToURL( | 485 GURL WebUIBrowserTest::WebUITestDataPathToURL( |
486 const base::FilePath::StringType& path) { | 486 const base::FilePath::StringType& path) { |
487 base::FilePath dir_test_data; | 487 base::FilePath dir_test_data; |
488 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); | 488 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); |
489 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); | 489 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); |
490 EXPECT_TRUE(base::PathExists(test_path)); | 490 EXPECT_TRUE(base::PathExists(test_path)); |
491 return net::FilePathToFileURL(test_path); | 491 return net::FilePathToFileURL(test_path); |
492 } | 492 } |
OLD | NEW |