summaryrefslogtreecommitdiffstats
path: root/sync/js
diff options
context:
space:
mode:
authordubroy@chromium.org <dubroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 12:25:17 +0000
committerdubroy@chromium.org <dubroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 12:25:17 +0000
commit5c3c67373ea9d304c65c5a54395cba803d98f2f0 (patch)
tree2da691242b6708b0692d4c3039181686e590a315 /sync/js
parent713629b4eacb45f85d82f01f0b90aa6bac242185 (diff)
downloadchromium_src-5c3c67373ea9d304c65c5a54395cba803d98f2f0.zip
chromium_src-5c3c67373ea9d304c65c5a54395cba803d98f2f0.tar.gz
chromium_src-5c3c67373ea9d304c65c5a54395cba803d98f2f0.tar.bz2
Revert 238348 "Clean up TestProfileSyncService and related tests"
This CL appeared to be the cause of a link failure on Win dbg: http://goo.gl/PTFpFF > Clean up TestProfileSyncService and related tests > > This CL refactors many of the tests in profile_sync_service_unittest.cc. > It continues the refactoring work begun in r233533, r235661, and > r235854. > > The JsController tests have been deleted. There is not much point in > testing the JsController here; it can be more easily tested on its own > in sync_js_controller_uniittest.cc. The SyncJsController unit tests > have been updated so they now cover the few cases that were formerly > only exercised in the ProfileSyncService unit tests. > > It converts all remaining uncoverted tests from relying on the > TestProfileSyncService to using a real ProfileSyncService with an > injected backend. The injected backend makes it easier to create the > scenarios we want to test. We can inject a specially crafted SBH rather > than fiddling with "synchronous init" and "fail initial download" flags. > > Since the TestProfileSyncService no longer needs to support the wide > variety of test scenarios required by the tests in > profile_sync_service_unittest.cc, we can greatly simplify its > implementation. Many of its parameters and associated code have been > removed. > > BUG=140354,312994 > > Review URL: https://codereview.chromium.org/67683005 TBR=rlarocque@chromium.org Review URL: https://codereview.chromium.org/98323003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/js')
-rw-r--r--sync/js/sync_js_controller_unittest.cc55
1 files changed, 17 insertions, 38 deletions
diff --git a/sync/js/sync_js_controller_unittest.cc b/sync/js/sync_js_controller_unittest.cc
index eca617c..ac46935 100644
--- a/sync/js/sync_js_controller_unittest.cc
+++ b/sync/js/sync_js_controller_unittest.cc
@@ -30,15 +30,10 @@ class SyncJsControllerTest : public testing::Test {
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 @@ TEST_F(SyncJsControllerTest, Messages) {
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, Messages) {
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 @@ TEST_F(SyncJsControllerTest, QueuedMessages) {
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);
-
- // Should call the queued messages.
+ // 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_reply_handler, HandleJsReply("test1_reply", _));
- EXPECT_CALL(mock_reply_handler, HandleJsReply("test2_reply", _));
+ EXPECT_CALL(mock_backend, ProcessJsMessage("test1", HasArgs(args2), _));
+ EXPECT_CALL(mock_backend, ProcessJsMessage("test2", HasArgs(args1), _));
+ // Should call the queued messages.
sync_js_controller.AttachJsBackend(mock_backend.AsWeakHandle());
PumpLoop();