| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 43 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 using content::RenderViewHost; | 46 using content::RenderViewHost; |
| 47 using content::WebContents; | 47 using content::WebContents; |
| 48 using content::WebUIController; | 48 using content::WebUIController; |
| 49 using content::WebUIMessageHandler; | 49 using content::WebUIMessageHandler; |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 base::LazyInstance<std::vector<std::string> > error_messages_ = | 53 base::LazyInstance<std::vector<std::string>>::DestructorAtExit error_messages_ = |
| 54 LAZY_INSTANCE_INITIALIZER; | 54 LAZY_INSTANCE_INITIALIZER; |
| 55 | 55 |
| 56 // Intercepts all log messages. | 56 // Intercepts all log messages. |
| 57 bool LogHandler(int severity, | 57 bool LogHandler(int severity, |
| 58 const char* file, | 58 const char* file, |
| 59 int line, | 59 int line, |
| 60 size_t message_start, | 60 size_t message_start, |
| 61 const std::string& str) { | 61 const std::string& str) { |
| 62 if (severity == logging::LOG_ERROR && file && | 62 if (severity == logging::LOG_ERROR && file && |
| 63 std::string("CONSOLE") == file) { | 63 std::string("CONSOLE") == file) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 WebUIController* controller = new content::WebUIController(web_ui); | 358 WebUIController* controller = new content::WebUIController(web_ui); |
| 359 Profile* profile = Profile::FromWebUI(web_ui); | 359 Profile* profile = Profile::FromWebUI(web_ui); |
| 360 content::URLDataSource::Add(profile, new MockWebUIDataSource()); | 360 content::URLDataSource::Add(profile, new MockWebUIDataSource()); |
| 361 return controller; | 361 return controller; |
| 362 } | 362 } |
| 363 | 363 |
| 364 private: | 364 private: |
| 365 DISALLOW_COPY_AND_ASSIGN(MockWebUIProvider); | 365 DISALLOW_COPY_AND_ASSIGN(MockWebUIProvider); |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 base::LazyInstance<MockWebUIProvider> mock_provider_ = | 368 base::LazyInstance<MockWebUIProvider>::DestructorAtExit mock_provider_ = |
| 369 LAZY_INSTANCE_INITIALIZER; | 369 LAZY_INSTANCE_INITIALIZER; |
| 370 | 370 |
| 371 } // namespace | 371 } // namespace |
| 372 | 372 |
| 373 void WebUIBrowserTest::SetUpOnMainThread() { | 373 void WebUIBrowserTest::SetUpOnMainThread() { |
| 374 JavaScriptBrowserTest::SetUpOnMainThread(); | 374 JavaScriptBrowserTest::SetUpOnMainThread(); |
| 375 | 375 |
| 376 logging::SetLogMessageHandler(&LogHandler); | 376 logging::SetLogMessageHandler(&LogHandler); |
| 377 | 377 |
| 378 AddLibrary(base::FilePath(kA11yAuditLibraryJSPath)); | 378 AddLibrary(base::FilePath(kA11yAuditLibraryJSPath)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 } | 489 } |
| 490 | 490 |
| 491 GURL WebUIBrowserTest::WebUITestDataPathToURL( | 491 GURL WebUIBrowserTest::WebUITestDataPathToURL( |
| 492 const base::FilePath::StringType& path) { | 492 const base::FilePath::StringType& path) { |
| 493 base::FilePath dir_test_data; | 493 base::FilePath dir_test_data; |
| 494 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); | 494 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); |
| 495 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); | 495 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); |
| 496 EXPECT_TRUE(base::PathExists(test_path)); | 496 EXPECT_TRUE(base::PathExists(test_path)); |
| 497 return net::FilePathToFileURL(test_path); | 497 return net::FilePathToFileURL(test_path); |
| 498 } | 498 } |
| OLD | NEW |