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

Side by Side Diff: sync/internal_api/sync_rollback_manager_base_unittest.cc

Issue 451743002: Pass args to SyncManager::Init via a struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use scoped_ptr instead of raw pointer. Created 6 years, 4 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 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 "sync/internal_api/sync_rollback_manager_base.h" 5 #include "sync/internal_api/sync_rollback_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "sync/internal_api/public/read_node.h" 8 #include "sync/internal_api/public/read_node.h"
9 #include "sync/internal_api/public/read_transaction.h" 9 #include "sync/internal_api/public/read_transaction.h"
10 #include "sync/internal_api/public/test/test_internal_components_factory.h" 10 #include "sync/internal_api/public/test/test_internal_components_factory.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace syncer { 14 namespace syncer {
15 15
16 namespace { 16 namespace {
17 17
18 void OnConfigDone(bool success) { 18 void OnConfigDone(bool success) {
19 EXPECT_TRUE(success); 19 EXPECT_TRUE(success);
20 } 20 }
21 21
22 class SyncTestRollbackManager : public SyncRollbackManagerBase { 22 class SyncTestRollbackManager : public SyncRollbackManagerBase {
23 public: 23 public:
24 virtual void Init( 24 virtual void Init(InitArgs* args) OVERRIDE {
25 const base::FilePath& database_location, 25 SyncRollbackManagerBase::InitInternal(
26 const WeakHandle<JsEventHandler>& event_handler, 26 args->database_location,
27 const GURL& service_url, 27 args->internal_components_factory.get(),
28 scoped_ptr<HttpPostProviderFactory> post_factory, 28 args->unrecoverable_error_handler.Pass(),
29 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, 29 args->report_unrecoverable_error_function);
30 ExtensionsActivity* extensions_activity,
31 ChangeDelegate* change_delegate,
32 const SyncCredentials& credentials,
33 const std::string& invalidator_client_id,
34 const std::string& restored_key_for_bootstrapping,
35 const std::string& restored_keystore_key_for_bootstrapping,
36 InternalComponentsFactory* internal_components_factory,
37 Encryptor* encryptor,
38 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
39 ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
40 CancelationSignal* cancelation_signal) OVERRIDE {
41 SyncRollbackManagerBase::InitInternal(database_location,
42 internal_components_factory,
43 unrecoverable_error_handler.Pass(),
44 report_unrecoverable_error_function);
45 } 30 }
46 }; 31 };
47 32
48 class SyncRollbackManagerBaseTest : public testing::Test { 33 class SyncRollbackManagerBaseTest : public testing::Test {
49 protected: 34 protected:
50 virtual void SetUp() OVERRIDE { 35 virtual void SetUp() OVERRIDE {
51 TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(), 36 SyncManager::InitArgs args;
52 STORAGE_IN_MEMORY); 37 args.database_location = base::FilePath(base::FilePath::kCurrentDirectory);
53 manager_.Init(base::FilePath(base::FilePath::kCurrentDirectory), 38 args.service_url = GURL("https://example.com/");
54 MakeWeakHandle(base::WeakPtr<JsEventHandler>()), 39 args.internal_components_factory.reset(new TestInternalComponentsFactory(
55 GURL("https://example.com/"), 40 InternalComponentsFactory::Switches(), STORAGE_IN_MEMORY));
56 scoped_ptr<HttpPostProviderFactory>().Pass(), 41 manager_.Init(&args);
57 std::vector<scoped_refptr<ModelSafeWorker> >(),
58 NULL,
59 NULL,
60 SyncCredentials(),
61 "",
62 "",
63 "",
64 &factory,
65 NULL,
66 scoped_ptr<UnrecoverableErrorHandler>().Pass(),
67 NULL,
68 NULL);
69 } 42 }
70 43
71 SyncTestRollbackManager manager_; 44 SyncTestRollbackManager manager_;
72 base::MessageLoop loop_; // Needed for WeakHandle 45 base::MessageLoop loop_; // Needed for WeakHandle
73 }; 46 };
74 47
75 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) { 48 TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) {
76 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty()); 49 EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty());
77 50
78 manager_.ConfigureSyncer( 51 manager_.ConfigureSyncer(
(...skipping 18 matching lines...) Expand all
97 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD, 70 EXPECT_EQ(BaseNode::INIT_FAILED_ENTRY_NOT_GOOD,
98 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks")); 71 bookmark_mobile.InitByTagLookupForBookmarks("synced_bookmarks"));
99 ReadNode bookmark_other(&trans); 72 ReadNode bookmark_other(&trans);
100 EXPECT_EQ(BaseNode::INIT_OK, 73 EXPECT_EQ(BaseNode::INIT_OK,
101 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks")); 74 bookmark_other.InitByTagLookupForBookmarks("other_bookmarks"));
102 } 75 }
103 76
104 } // anonymous namespace 77 } // anonymous namespace
105 78
106 } // namespace syncer 79 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_rollback_manager.cc ('k') | sync/internal_api/sync_rollback_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698