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

Side by Side Diff: chrome/test/base/web_ui_browser_test_browsertest.cc

Issue 1100223002: Update {virtual,override} to follow C++11 style in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 8 months 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
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/webui/async_gen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Class to synchronize asynchronous javascript activity with the tests. 101 // Class to synchronize asynchronous javascript activity with the tests.
102 class AsyncWebUIMessageHandler : public WebUIMessageHandler { 102 class AsyncWebUIMessageHandler : public WebUIMessageHandler {
103 public: 103 public:
104 AsyncWebUIMessageHandler() {} 104 AsyncWebUIMessageHandler() {}
105 105
106 MOCK_METHOD1(HandleTestContinues, void(const base::ListValue*)); 106 MOCK_METHOD1(HandleTestContinues, void(const base::ListValue*));
107 MOCK_METHOD1(HandleTestFails, void(const base::ListValue*)); 107 MOCK_METHOD1(HandleTestFails, void(const base::ListValue*));
108 MOCK_METHOD1(HandleTestPasses, void(const base::ListValue*)); 108 MOCK_METHOD1(HandleTestPasses, void(const base::ListValue*));
109 109
110 private: 110 private:
111 virtual void RegisterMessages() override { 111 void RegisterMessages() override {
112 web_ui()->RegisterMessageCallback("startAsyncTest", 112 web_ui()->RegisterMessageCallback("startAsyncTest",
113 base::Bind(&AsyncWebUIMessageHandler::HandleStartAsyncTest, 113 base::Bind(&AsyncWebUIMessageHandler::HandleStartAsyncTest,
114 base::Unretained(this))); 114 base::Unretained(this)));
115 web_ui()->RegisterMessageCallback("testContinues", 115 web_ui()->RegisterMessageCallback("testContinues",
116 base::Bind(&AsyncWebUIMessageHandler::HandleTestContinues, 116 base::Bind(&AsyncWebUIMessageHandler::HandleTestContinues,
117 base::Unretained(this))); 117 base::Unretained(this)));
118 web_ui()->RegisterMessageCallback("testFails", 118 web_ui()->RegisterMessageCallback("testFails",
119 base::Bind(&AsyncWebUIMessageHandler::HandleTestFails, 119 base::Bind(&AsyncWebUIMessageHandler::HandleTestFails,
120 base::Unretained(this))); 120 base::Unretained(this)));
121 web_ui()->RegisterMessageCallback("testPasses", 121 web_ui()->RegisterMessageCallback("testPasses",
122 base::Bind(&AsyncWebUIMessageHandler::HandleTestPasses, 122 base::Bind(&AsyncWebUIMessageHandler::HandleTestPasses,
123 base::Unretained(this))); 123 base::Unretained(this)));
124 } 124 }
125 125
126 // Starts the test in |list_value|[0] with the runAsync wrapper. 126 // Starts the test in |list_value|[0] with the runAsync wrapper.
127 void HandleStartAsyncTest(const base::ListValue* list_value) { 127 void HandleStartAsyncTest(const base::ListValue* list_value) {
128 const base::Value* test_name; 128 const base::Value* test_name;
129 ASSERT_TRUE(list_value->Get(0, &test_name)); 129 ASSERT_TRUE(list_value->Get(0, &test_name));
130 web_ui()->CallJavascriptFunction("runAsync", *test_name); 130 web_ui()->CallJavascriptFunction("runAsync", *test_name);
131 } 131 }
132 132
133 DISALLOW_COPY_AND_ASSIGN(AsyncWebUIMessageHandler); 133 DISALLOW_COPY_AND_ASSIGN(AsyncWebUIMessageHandler);
134 }; 134 };
135 135
136 // Handler for this object. 136 // Handler for this object.
137 ::testing::StrictMock<AsyncWebUIMessageHandler> message_handler_; 137 ::testing::StrictMock<AsyncWebUIMessageHandler> message_handler_;
138 138
139 private: 139 private:
140 // Provide this object's handler. 140 // Provide this object's handler.
141 virtual WebUIMessageHandler* GetMockMessageHandler() override { 141 WebUIMessageHandler* GetMockMessageHandler() override {
142 return &message_handler_; 142 return &message_handler_;
143 } 143 }
144 144
145 // Set up and browse to kDummyURL for all tests. 145 // Set up and browse to kDummyURL for all tests.
146 virtual void SetUpOnMainThread() override { 146 void SetUpOnMainThread() override {
147 WebUIBrowserTest::SetUpOnMainThread(); 147 WebUIBrowserTest::SetUpOnMainThread();
148 AddLibrary(base::FilePath(FILE_PATH_LITERAL("async.js"))); 148 AddLibrary(base::FilePath(FILE_PATH_LITERAL("async.js")));
149 ui_test_utils::NavigateToURL(browser(), GURL(kDummyURL)); 149 ui_test_utils::NavigateToURL(browser(), GURL(kDummyURL));
150 } 150 }
151 151
152 DISALLOW_COPY_AND_ASSIGN(WebUIBrowserAsyncTest); 152 DISALLOW_COPY_AND_ASSIGN(WebUIBrowserAsyncTest);
153 }; 153 };
154 154
155 // Test that assertions fail immediately after assertion fails (no testContinues 155 // Test that assertions fail immediately after assertion fails (no testContinues
156 // message). (Sync version). 156 // message). (Sync version).
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // testDone directly and expect pass result. 236 // testDone directly and expect pass result.
237 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { 237 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) {
238 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); 238 ASSERT_TRUE(RunJavascriptAsyncTest("testDone"));
239 } 239 }
240 240
241 // Test that calling testDone during RunJavascriptTest still completes when 241 // Test that calling testDone during RunJavascriptTest still completes when
242 // waiting for async result. 242 // waiting for async result.
243 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { 243 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) {
244 ASSERT_TRUE(RunJavascriptTest("testDone")); 244 ASSERT_TRUE(RunJavascriptTest("testDone"));
245 } 245 }
OLDNEW
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/webui/async_gen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698