diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-07 20:30:34 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-07 20:30:34 +0000 |
commit | c77435705b8f6a9173cdecc5e6eeb2f1911cc48a (patch) | |
tree | 8d1113110fed798c28e18124c68440baeaeed88d /sync/internal_api/sync_manager_impl_unittest.cc | |
parent | e5af9bcbb29f9207de974e278e614ebc0609ea08 (diff) | |
download | chromium_src-c77435705b8f6a9173cdecc5e6eeb2f1911cc48a.zip chromium_src-c77435705b8f6a9173cdecc5e6eeb2f1911cc48a.tar.gz chromium_src-c77435705b8f6a9173cdecc5e6eeb2f1911cc48a.tar.bz2 |
sync: Re-implement getAllNodes WebUI function
Removes the existing implementation of getAllNodes. This was the last
function based on the old "makeSyncFunction" and "JsMessageHandler"
interface, so its removal leaves behind quite a bit of dead code. This
CL removes some of it. The rest will be removed in a future CL.
Replaces it with some infrastructure intended to be more compatible with
the future of sync, where each type is more independent. Requests to
getAllNodes are routed through a DirectoryTypeDebugInfoEmitter in the
ModelTypeRegistry. A NonBlockingTypeDebugInfoEmitter will be
implemented in a future CL.
The new system also intended to support "streaming" results. Rather
than waiting for all types to return their nodes, the system could be
modified to allow some types to get back to the JavaScript layer sooner
than others so it can display results earlier. However, we do not
currently take advantage of this functionality.
The return type of getAllNodes is now an array of per-type objects,
rather than one big list of nodes. This, too, should help us implement
streaming support in the future. For now, most of the JavaScript
callbacks will convert the data back to the old format before operating
on it.
BUG=328606
Review URL: https://codereview.chromium.org/224563004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/sync_manager_impl_unittest.cc')
-rw-r--r-- | sync/internal_api/sync_manager_impl_unittest.cc | 50 |
1 files changed, 9 insertions, 41 deletions
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc index 7da7070..a8ee0be 100644 --- a/sync/internal_api/sync_manager_impl_unittest.cc +++ b/sync/internal_api/sync_manager_impl_unittest.cc @@ -42,10 +42,8 @@ #include "sync/internal_api/sync_encryption_handler_impl.h" #include "sync/internal_api/sync_manager_impl.h" #include "sync/internal_api/syncapi_internal.h" -#include "sync/js/js_arg_list.h" #include "sync/js/js_backend.h" #include "sync/js/js_event_handler.h" -#include "sync/js/js_reply_handler.h" #include "sync/js/js_test_util.h" #include "sync/notifier/fake_invalidation_handler.h" #include "sync/notifier/invalidation_handler.h" @@ -754,6 +752,7 @@ class SyncManagerTest : public testing::Test, sync_manager_.GetUserShare(), i->first); } } + PumpLoop(); } @@ -836,13 +835,6 @@ class SyncManagerTest : public testing::Test, message_loop_.RunUntilIdle(); } - void SendJsMessage(const std::string& name, const JsArgList& args, - const WeakHandle<JsReplyHandler>& reply_handler) { - js_backend_.Call(FROM_HERE, &JsBackend::ProcessJsMessage, - name, args, reply_handler); - PumpLoop(); - } - void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler) { js_backend_.Call(FROM_HERE, &JsBackend::SetJsEventHandler, event_handler); @@ -938,42 +930,18 @@ class SyncManagerTest : public testing::Test, InternalComponentsFactory::Switches switches_; }; -TEST_F(SyncManagerTest, GetAllNodesTest) { - StrictMock<MockJsReplyHandler> reply_handler; - JsArgList return_args; +TEST_F(SyncManagerTest, GetAllNodesForTypeTest) { + ModelSafeRoutingInfo routing_info; + GetModelSafeRoutingInfo(&routing_info); + sync_manager_.StartSyncingNormally(routing_info); - EXPECT_CALL(reply_handler, - HandleJsReply("getAllNodes", _)) - .Times(1).WillRepeatedly(SaveArg<1>(&return_args)); + scoped_ptr<base::ListValue> node_list( + sync_manager_.GetAllNodesForType(syncer::PREFERENCES)); - { - base::ListValue args; - SendJsMessage("getAllNodes", - JsArgList(&args), reply_handler.AsWeakHandle()); - } - - // There's not much value in verifying every attribute on every node here. - // Most of the value of this test has already been achieved: we've verified we - // can call the above function without crashing or leaking memory. - // - // Let's just check the list size and a few of its elements. Anything more - // would make this test brittle without greatly increasing our chances of - // catching real bugs. + // Should have one node: the type root node. + ASSERT_EQ(1U, node_list->GetSize()); - const base::ListValue* node_list; const base::DictionaryValue* first_result; - - // The resulting argument list should have one argument, a list of nodes. - ASSERT_EQ(1U, return_args.Get().GetSize()); - ASSERT_TRUE(return_args.Get().GetList(0, &node_list)); - - // The database creation logic depends on the routing info. - // Refer to setup methods for more information. - ModelSafeRoutingInfo routes; - GetModelSafeRoutingInfo(&routes); - size_t directory_size = routes.size() + 1; - - ASSERT_EQ(directory_size, node_list->GetSize()); ASSERT_TRUE(node_list->GetDictionary(0, &first_result)); EXPECT_TRUE(first_result->HasKey("ID")); EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME")); |