Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: chrome/browser/ui/webui/web_ui_browsertest.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: thakis comment, renamed LAZY_INSTANCE_INITIALIZER Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 #include "content/browser/tab_contents/tab_contents.h" 24 #include "content/browser/tab_contents/tab_contents.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest-spi.h" 26 #include "testing/gtest/include/gtest/gtest-spi.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 28
29 namespace { 29 namespace {
30 30
31 const FilePath::CharType kMockJS[] = FILE_PATH_LITERAL("mock4js.js"); 31 const FilePath::CharType kMockJS[] = FILE_PATH_LITERAL("mock4js.js");
32 const FilePath::CharType kWebUILibraryJS[] = FILE_PATH_LITERAL("test_api.js"); 32 const FilePath::CharType kWebUILibraryJS[] = FILE_PATH_LITERAL("test_api.js");
33 const FilePath::CharType kWebUITestFolder[] = FILE_PATH_LITERAL("webui"); 33 const FilePath::CharType kWebUITestFolder[] = FILE_PATH_LITERAL("webui");
34 base::LazyInstance<std::vector<std::string> > error_messages_( 34 base::LazyInstance<std::vector<std::string> > error_messages_ =
35 base::LINKER_INITIALIZED); 35 LAZY_INSTANCE_INITIALIZER;
36 36
37 // Intercepts all log messages. 37 // Intercepts all log messages.
38 bool LogHandler(int severity, 38 bool LogHandler(int severity,
39 const char* file, 39 const char* file,
40 int line, 40 int line,
41 size_t message_start, 41 size_t message_start,
42 const std::string& str) { 42 const std::string& str) {
43 if (severity == logging::LOG_ERROR && 43 if (severity == logging::LOG_ERROR &&
44 file && 44 file &&
45 std::string("CONSOLE") == file) { 45 std::string("CONSOLE") == file) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { 220 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider {
221 public: 221 public:
222 MockWebUIProvider() {} 222 MockWebUIProvider() {}
223 223
224 // Returns a new ChromeWebUI 224 // Returns a new ChromeWebUI
225 WebUI* NewWebUI(TabContents* tab_contents, const GURL& url) OVERRIDE { 225 WebUI* NewWebUI(TabContents* tab_contents, const GURL& url) OVERRIDE {
226 return new ChromeWebUI(tab_contents); 226 return new ChromeWebUI(tab_contents);
227 } 227 }
228 }; 228 };
229 229
230 base::LazyInstance<MockWebUIProvider> mock_provider_( 230 base::LazyInstance<MockWebUIProvider> mock_provider_ =
231 base::LINKER_INITIALIZED); 231 LAZY_INSTANCE_INITIALIZER;
232 232
233 } // namespace 233 } // namespace
234 234
235 void WebUIBrowserTest::SetUpOnMainThread() { 235 void WebUIBrowserTest::SetUpOnMainThread() {
236 InProcessBrowserTest::SetUpOnMainThread(); 236 InProcessBrowserTest::SetUpOnMainThread();
237 237
238 logging::SetLogMessageHandler(&LogHandler); 238 logging::SetLogMessageHandler(&LogHandler);
239 } 239 }
240 240
241 void WebUIBrowserTest::CleanUpOnMainThread() { 241 void WebUIBrowserTest::CleanUpOnMainThread() {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // testDone directly and expect pass result. 620 // testDone directly and expect pass result.
621 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { 621 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) {
622 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); 622 ASSERT_TRUE(RunJavascriptAsyncTest("testDone"));
623 } 623 }
624 624
625 // Test that calling testDone during RunJavascriptTest still completes when 625 // Test that calling testDone during RunJavascriptTest still completes when
626 // waiting for async result. 626 // waiting for async result.
627 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { 627 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) {
628 ASSERT_TRUE(RunJavascriptTest("testDone")); 628 ASSERT_TRUE(RunJavascriptTest("testDone"));
629 } 629 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698