1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sync/internal_api/sync_rollback_manager_base.h"
#include "base/bind.h"
#include "sync/internal_api/public/read_node.h"
#include "sync/internal_api/public/read_transaction.h"
#include "sync/internal_api/public/test/test_internal_components_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
namespace {
void OnConfigDone(bool success) {
EXPECT_TRUE(success);
}
class SyncRollbackManagerBaseTest : public testing::Test {
protected:
virtual void SetUp() OVERRIDE {
TestInternalComponentsFactory factory(InternalComponentsFactory::Switches(),
STORAGE_IN_MEMORY);
manager_.Init(base::FilePath(base::FilePath::kCurrentDirectory),
MakeWeakHandle(base::WeakPtr<JsEventHandler>()),
"", 0, true, scoped_ptr<HttpPostProviderFactory>().Pass(),
std::vector<scoped_refptr<ModelSafeWorker> >(),
NULL, NULL, SyncCredentials(), "", "", "", &factory,
NULL, scoped_ptr<UnrecoverableErrorHandler>().Pass(),
NULL, NULL);
}
SyncRollbackManagerBase manager_;
base::MessageLoop loop_; // Needed for WeakHandle
};
TEST_F(SyncRollbackManagerBaseTest, InitTypeOnConfiguration) {
EXPECT_TRUE(manager_.InitialSyncEndedTypes().Empty());
manager_.ConfigureSyncer(
CONFIGURE_REASON_NEW_CLIENT,
ModelTypeSet(PREFERENCES, BOOKMARKS),
ModelTypeSet(), ModelTypeSet(), ModelTypeSet(), ModelSafeRoutingInfo(),
base::Bind(&OnConfigDone, true),
base::Bind(&OnConfigDone, false));
ReadTransaction trans(FROM_HERE, manager_.GetUserShare());
ReadNode pref_root(&trans);
EXPECT_EQ(BaseNode::INIT_OK,
pref_root.InitByTagLookup(ModelTypeToRootTag(PREFERENCES)));
ReadNode bookmark_root(&trans);
EXPECT_EQ(BaseNode::INIT_OK,
bookmark_root.InitByTagLookup(ModelTypeToRootTag(BOOKMARKS)));
ReadNode bookmark_bar(&trans);
EXPECT_EQ(BaseNode::INIT_OK,
bookmark_bar.InitByTagLookup("bookmark_bar"));
ReadNode bookmark_mobile(&trans);
EXPECT_EQ(BaseNode::INIT_OK,
bookmark_mobile.InitByTagLookup("synced_bookmarks"));
ReadNode bookmark_other(&trans);
EXPECT_EQ(BaseNode::INIT_OK,
bookmark_other.InitByTagLookup("other_bookmarks"));
}
} // anonymous namespace
} // namespace syncer
|