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

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

Issue 6735004: Move extension messages to their own file and add a RenderViewObserver to start moving the extens... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | 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 4
5 #include "chrome/browser/ui/webui/sync_internals_ui.h" 5 #include "chrome/browser/ui/webui/sync_internals_ui.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <string> 8 #include <string>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/sync/js_arg_list.h" 12 #include "chrome/browser/sync/js_arg_list.h"
13 #include "chrome/browser/sync/js_test_util.h" 13 #include "chrome/browser/sync/js_test_util.h"
14 #include "chrome/browser/sync/profile_sync_service_mock.h" 14 #include "chrome/browser/sync/profile_sync_service_mock.h"
15 #include "chrome/common/render_messages_params.h" 15 #include "chrome/common/extensions/extension_messages.h"
16 #include "chrome/test/profile_mock.h" 16 #include "chrome/test/profile_mock.h"
17 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
18 #include "content/browser/renderer_host/test_render_view_host.h" 18 #include "content/browser/renderer_host/test_render_view_host.h"
19 #include "content/browser/tab_contents/test_tab_contents.h" 19 #include "content/browser/tab_contents/test_tab_contents.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace { 23 namespace {
24 24
25 using browser_sync::HasArgsAsList; 25 using browser_sync::HasArgsAsList;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 ListValue args; 158 ListValue args;
159 args.Append(Value::CreateIntegerValue(5)); 159 args.Append(Value::CreateIntegerValue(5));
160 args.Append(Value::CreateBooleanValue(true)); 160 args.Append(Value::CreateBooleanValue(true));
161 GetTestSyncInternalsUI()->HandleJsEvent("testMessage", JsArgList(args)); 161 GetTestSyncInternalsUI()->HandleJsEvent("testMessage", JsArgList(args));
162 } 162 }
163 163
164 TEST_F(SyncInternalsUITest, ProcessWebUIMessageBasic) { 164 TEST_F(SyncInternalsUITest, ProcessWebUIMessageBasic) {
165 ExpectSetupTeardownCalls(); 165 ExpectSetupTeardownCalls();
166 166
167 ViewHostMsg_DomMessage_Params params; 167 ExtensionHostMsg_DomMessage_Params params;
168 params.name = "testName"; 168 params.name = "testName";
169 params.arguments.Append(Value::CreateIntegerValue(10)); 169 params.arguments.Append(Value::CreateIntegerValue(10));
170 170
171 EXPECT_CALL(mock_js_backend_, 171 EXPECT_CALL(mock_js_backend_,
172 ProcessMessage(params.name, HasArgsAsList(params.arguments), 172 ProcessMessage(params.name, HasArgsAsList(params.arguments),
173 GetTestSyncInternalsUIAddress())); 173 GetTestSyncInternalsUIAddress()));
174 174
175 ConstructTestSyncInternalsUI(); 175 ConstructTestSyncInternalsUI();
176 176
177 GetTestSyncInternalsUI()->ProcessWebUIMessage(params); 177 GetTestSyncInternalsUI()->ProcessWebUIMessage(params);
178 } 178 }
179 179
180 TEST_F(SyncInternalsUITest, ProcessWebUIMessageBasicNullService) { 180 TEST_F(SyncInternalsUITest, ProcessWebUIMessageBasicNullService) {
181 ExpectSetupTeardownCallsNullService(); 181 ExpectSetupTeardownCallsNullService();
182 182
183 ConstructTestSyncInternalsUI(); 183 ConstructTestSyncInternalsUI();
184 184
185 ViewHostMsg_DomMessage_Params params; 185 ExtensionHostMsg_DomMessage_Params params;
186 params.name = "testName"; 186 params.name = "testName";
187 params.arguments.Append(Value::CreateIntegerValue(5)); 187 params.arguments.Append(Value::CreateIntegerValue(5));
188 188
189 // Should drop the message. 189 // Should drop the message.
190 GetTestSyncInternalsUI()->ProcessWebUIMessage(params); 190 GetTestSyncInternalsUI()->ProcessWebUIMessage(params);
191 } 191 }
192 192
193 namespace { 193 namespace {
194 const char kAboutInfoCall[] = 194 const char kAboutInfoCall[] =
195 "onGetAboutInfoFinished({\"summary\":\"SYNC DISABLED\"});"; 195 "onGetAboutInfoFinished({\"summary\":\"SYNC DISABLED\"});";
196 } // namespace 196 } // namespace
197 197
198 TEST_F(SyncInternalsUITest, ProcessWebUIMessageGetAboutInfo) { 198 TEST_F(SyncInternalsUITest, ProcessWebUIMessageGetAboutInfo) {
199 ExpectSetupTeardownCalls(); 199 ExpectSetupTeardownCalls();
200 200
201 ViewHostMsg_DomMessage_Params params; 201 ExtensionHostMsg_DomMessage_Params params;
202 params.name = "getAboutInfo"; 202 params.name = "getAboutInfo";
203 203
204 ConstructTestSyncInternalsUI(); 204 ConstructTestSyncInternalsUI();
205 205
206 EXPECT_CALL(*GetTestSyncInternalsUI(), 206 EXPECT_CALL(*GetTestSyncInternalsUI(),
207 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall))); 207 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall)));
208 208
209 GetTestSyncInternalsUI()->ProcessWebUIMessage(params); 209 GetTestSyncInternalsUI()->ProcessWebUIMessage(params);
210 } 210 }
211 211
212 TEST_F(SyncInternalsUITest, ProcessWebUIMessageGetAboutInfoNullService) { 212 TEST_F(SyncInternalsUITest, ProcessWebUIMessageGetAboutInfoNullService) {
213 ExpectSetupTeardownCallsNullService(); 213 ExpectSetupTeardownCallsNullService();
214 214
215 ViewHostMsg_DomMessage_Params params; 215 ExtensionHostMsg_DomMessage_Params params;
216 params.name = "getAboutInfo"; 216 params.name = "getAboutInfo";
217 217
218 ConstructTestSyncInternalsUI(); 218 ConstructTestSyncInternalsUI();
219 219
220 EXPECT_CALL(*GetTestSyncInternalsUI(), 220 EXPECT_CALL(*GetTestSyncInternalsUI(),
221 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall))); 221 ExecuteJavascript(ASCIIToUTF16(kAboutInfoCall)));
222 222
223 GetTestSyncInternalsUI()->ProcessWebUIMessage(params); 223 GetTestSyncInternalsUI()->ProcessWebUIMessage(params);
224 } 224 }
225 225
226 } // namespace 226 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_ui.cc ('k') | chrome/browser/web_applications/web_app_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698