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

Unified Diff: trunk/src/sync/js/sync_js_controller_unittest.cc

Issue 98323003: Revert 238348 "Clean up TestProfileSyncService and related tests" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/sync/internal_api/test/sync_manager_for_profile_sync_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/sync/js/sync_js_controller_unittest.cc
===================================================================
--- trunk/src/sync/js/sync_js_controller_unittest.cc (revision 238367)
+++ trunk/src/sync/js/sync_js_controller_unittest.cc (working copy)
@@ -30,15 +30,10 @@
base::MessageLoop message_loop_;
};
-ACTION_P(ReplyToMessage, reply_name) {
- arg2.Call(FROM_HERE, &JsReplyHandler::HandleJsReply, reply_name, JsArgList());
-}
-
TEST_F(SyncJsControllerTest, Messages) {
InSequence dummy;
// |mock_backend| needs to outlive |sync_js_controller|.
StrictMock<MockJsBackend> mock_backend;
- StrictMock<MockJsReplyHandler> mock_reply_handler;
SyncJsController sync_js_controller;
base::ListValue arg_list1, arg_list2;
@@ -46,23 +41,17 @@
arg_list2.Append(new base::FundamentalValue(5));
JsArgList args1(&arg_list1), args2(&arg_list2);
+ // TODO(akalin): Write matchers for WeakHandle and use them here
+ // instead of _.
EXPECT_CALL(mock_backend, SetJsEventHandler(_));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test1", HasArgs(args2), _))
- .WillOnce(ReplyToMessage("test1_reply"));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test2", HasArgs(args1), _))
- .WillOnce(ReplyToMessage("test2_reply"));
+ EXPECT_CALL(mock_backend, ProcessJsMessage("test1", HasArgs(args2), _));
+ EXPECT_CALL(mock_backend, ProcessJsMessage("test2", HasArgs(args1), _));
sync_js_controller.AttachJsBackend(mock_backend.AsWeakHandle());
- sync_js_controller.ProcessJsMessage("test1",
- args2,
- mock_reply_handler.AsWeakHandle());
- sync_js_controller.ProcessJsMessage("test2",
- args1,
- mock_reply_handler.AsWeakHandle());
-
- // The replies should be waiting on our message loop.
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test1_reply", _));
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test2_reply", _));
+ sync_js_controller.ProcessJsMessage("test1", args2,
+ WeakHandle<JsReplyHandler>());
+ sync_js_controller.ProcessJsMessage("test2", args1,
+ WeakHandle<JsReplyHandler>());
PumpLoop();
// Let destructor of |sync_js_controller| call RemoveBackend().
@@ -71,7 +60,6 @@
TEST_F(SyncJsControllerTest, QueuedMessages) {
// |mock_backend| needs to outlive |sync_js_controller|.
StrictMock<MockJsBackend> mock_backend;
- StrictMock<MockJsReplyHandler> mock_reply_handler;
SyncJsController sync_js_controller;
base::ListValue arg_list1, arg_list2;
@@ -80,29 +68,20 @@
JsArgList args1(&arg_list1), args2(&arg_list2);
// Should queue messages.
- sync_js_controller.ProcessJsMessage(
- "test1",
- args2,
- mock_reply_handler.AsWeakHandle());
- sync_js_controller.ProcessJsMessage(
- "test2",
- args1,
- mock_reply_handler.AsWeakHandle());
+ sync_js_controller.ProcessJsMessage("test1", args2,
+ WeakHandle<JsReplyHandler>());
+ sync_js_controller.ProcessJsMessage("test2", args1,
+ WeakHandle<JsReplyHandler>());
- // Should do nothing.
- PumpLoop();
Mock::VerifyAndClearExpectations(&mock_backend);
+ // TODO(akalin): Write matchers for WeakHandle and use them here
+ // instead of _.
+ EXPECT_CALL(mock_backend, SetJsEventHandler(_));
+ EXPECT_CALL(mock_backend, ProcessJsMessage("test1", HasArgs(args2), _));
+ EXPECT_CALL(mock_backend, ProcessJsMessage("test2", HasArgs(args1), _));
// Should call the queued messages.
- EXPECT_CALL(mock_backend, SetJsEventHandler(_));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test1", HasArgs(args2), _))
- .WillOnce(ReplyToMessage("test1_reply"));
- EXPECT_CALL(mock_backend, ProcessJsMessage("test2", HasArgs(args1), _))
- .WillOnce(ReplyToMessage("test2_reply"));
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test1_reply", _));
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test2_reply", _));
-
sync_js_controller.AttachJsBackend(mock_backend.AsWeakHandle());
PumpLoop();
« no previous file with comments | « trunk/src/sync/internal_api/test/sync_manager_for_profile_sync_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698