blob: 632d4f4c85256de2fdd141d98db970bbca666a21 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
// Copyright (c) 2010 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.
#ifndef CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
#define CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
#include <vector>
#include "chrome/browser/browser.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/test/bookmark_load_observer.h"
#include "chrome/test/live_sync/bookmark_model_verifier.h"
#include "chrome/test/live_sync/live_sync_test.h"
#include "chrome/test/ui_test_utils.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
class LiveBookmarksSyncTest : public LiveSyncTest {
public:
explicit LiveBookmarksSyncTest(TestType test_type)
: LiveSyncTest(test_type) {}
virtual ~LiveBookmarksSyncTest() {}
// Sets up sync profiles and clients and initializes the verifier bookmark
// model.
virtual bool SetupClients() {
if (!LiveSyncTest::SetupClients())
return false;
for (int i = 0; i < num_clients(); ++i) {
ui_test_utils::WaitForBookmarkModelToLoad(
GetProfile(i)->GetBookmarkModel());
}
verifier_helper_.reset(BookmarkModelVerifier::Create(
GetVerifierBookmarkModel()));
return (verifier_helper_.get() != NULL);
}
// Used to access the bookmarks within a particular sync profile.
BookmarkModel* GetBookmarkModel(int index) {
return GetProfile(index)->GetBookmarkModel();
}
// Used to access the bookmark bar within a particular sync profile.
const BookmarkNode* GetBookmarkBarNode(int index) {
return GetBookmarkModel(index)->GetBookmarkBarNode();
}
// Used to access the bookmarks within the verifier sync profile.
BookmarkModel* GetVerifierBookmarkModel() {
return verifier()->GetBookmarkModel();
}
// Used to access the service object within a particular sync client.
ProfileSyncService* GetService(int index) {
return GetClient(index)->service();
}
// Used to access the BookmarkModelVerifier helper object.
BookmarkModelVerifier* verifier_helper() {
return verifier_helper_.get();
}
// Helper to get a handle on a bookmark in |m| when the url is known to be
// unique.
static const BookmarkNode* GetByUniqueURL(BookmarkModel* m, const GURL& url) {
std::vector<const BookmarkNode*> nodes;
m->GetNodesByURL(url, &nodes);
EXPECT_EQ(1U, nodes.size());
if (nodes.empty())
return NULL;
return nodes[0];
}
private:
// Helper object that has the functionality to verify changes made to the
// bookmarks of individual profiles.
scoped_ptr<BookmarkModelVerifier> verifier_helper_;
DISALLOW_COPY_AND_ASSIGN(LiveBookmarksSyncTest);
};
class SingleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
public:
SingleClientLiveBookmarksSyncTest()
: LiveBookmarksSyncTest(SINGLE_CLIENT) {}
~SingleClientLiveBookmarksSyncTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(SingleClientLiveBookmarksSyncTest);
};
class TwoClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
public:
TwoClientLiveBookmarksSyncTest()
: LiveBookmarksSyncTest(TWO_CLIENT) {}
~TwoClientLiveBookmarksSyncTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(TwoClientLiveBookmarksSyncTest);
};
class MultipleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
public:
MultipleClientLiveBookmarksSyncTest()
: LiveBookmarksSyncTest(MULTIPLE_CLIENT) {}
~MultipleClientLiveBookmarksSyncTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(MultipleClientLiveBookmarksSyncTest);
};
class ManyClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
public:
ManyClientLiveBookmarksSyncTest()
: LiveBookmarksSyncTest(MANY_CLIENT) {}
~ManyClientLiveBookmarksSyncTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(ManyClientLiveBookmarksSyncTest);
};
#endif // CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
|