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

Side by Side Diff: chrome/browser/sync/abstract_profile_sync_service_test.h

Issue 3127017: Revert 56423 - Added classes to enable session sync functionality.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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
« no previous file with comments | « chrome/browser/sessions/tab_restore_service.h ('k') | chrome/browser/sync/engine/syncapi.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ 5 #ifndef CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
6 #define CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ 6 #define CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "chrome/browser/chrome_thread.h" 14 #include "chrome/browser/chrome_thread.h"
15 #include "chrome/browser/sync/engine/syncapi.h" 15 #include "chrome/browser/sync/engine/syncapi.h"
16 #include "chrome/browser/sync/glue/autofill_model_associator.h" 16 #include "chrome/browser/sync/glue/autofill_model_associator.h"
17 #include "chrome/browser/sync/glue/password_model_associator.h" 17 #include "chrome/browser/sync/glue/password_model_associator.h"
18 #include "chrome/browser/sync/glue/preference_model_associator.h" 18 #include "chrome/browser/sync/glue/preference_model_associator.h"
19 #include "chrome/browser/sync/glue/session_model_associator.h"
20 #include "chrome/browser/sync/glue/typed_url_model_associator.h" 19 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
21 #include "chrome/browser/sync/profile_sync_factory_mock.h" 20 #include "chrome/browser/sync/profile_sync_factory_mock.h"
22 #include "chrome/browser/sync/protocol/sync.pb.h" 21 #include "chrome/browser/sync/protocol/sync.pb.h"
23 #include "chrome/browser/sync/syncable/directory_manager.h" 22 #include "chrome/browser/sync/syncable/directory_manager.h"
24 #include "chrome/browser/sync/syncable/model_type.h" 23 #include "chrome/browser/sync/syncable/model_type.h"
25 #include "chrome/browser/sync/syncable/syncable.h" 24 #include "chrome/browser/sync/syncable/syncable.h"
26 #include "chrome/browser/sync/test_profile_sync_service.h" 25 #include "chrome/browser/sync/test_profile_sync_service.h"
27 #include "chrome/browser/sync/util/cryptographer.h" 26 #include "chrome/browser/sync/util/cryptographer.h"
28 #include "chrome/test/profile_mock.h" 27 #include "chrome/test/profile_mock.h"
29 #include "chrome/test/sync/engine/test_id_factory.h" 28 #include "chrome/test/sync/engine/test_id_factory.h"
30 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
31 30
32 using browser_sync::TestIdFactory; 31 using browser_sync::TestIdFactory;
33 using sync_api::UserShare; 32 using sync_api::UserShare;
34 using syncable::BASE_VERSION; 33 using syncable::BASE_VERSION;
35 using syncable::CREATE; 34 using syncable::CREATE;
36 using syncable::DirectoryManager; 35 using syncable::DirectoryManager;
36 using syncable::ID;
37 using syncable::IS_DEL; 37 using syncable::IS_DEL;
38 using syncable::IS_DIR; 38 using syncable::IS_DIR;
39 using syncable::IS_UNAPPLIED_UPDATE; 39 using syncable::IS_UNAPPLIED_UPDATE;
40 using syncable::IS_UNSYNCED; 40 using syncable::IS_UNSYNCED;
41 using syncable::ModelType; 41 using syncable::ModelType;
42 using syncable::MutableEntry; 42 using syncable::MutableEntry;
43 using syncable::SERVER_IS_DIR; 43 using syncable::SERVER_IS_DIR;
44 using syncable::SERVER_VERSION; 44 using syncable::SERVER_VERSION;
45 using syncable::SPECIFICS; 45 using syncable::SPECIFICS;
46 using syncable::ScopedDirLookup; 46 using syncable::ScopedDirLookup;
47 using syncable::UNIQUE_SERVER_TAG; 47 using syncable::UNIQUE_SERVER_TAG;
48 using syncable::UNITTEST; 48 using syncable::UNITTEST;
49 using syncable::WriteTransaction; 49 using syncable::WriteTransaction;
50 50
51 class ProfileSyncServiceTestHelper { 51 class AbstractProfileSyncServiceTest : public testing::Test {
52 public: 52 public:
53 static bool CreateRoot(ModelType model_type, ProfileSyncService* service, 53 AbstractProfileSyncServiceTest()
54 TestIdFactory* ids) { 54 : ui_thread_(ChromeThread::UI, &message_loop_) {}
55 UserShare* user_share = service->backend()->GetUserShareHandle(); 55
56 bool CreateRoot(ModelType model_type) {
57 UserShare* user_share = service_->backend()->GetUserShareHandle();
56 DirectoryManager* dir_manager = user_share->dir_manager.get(); 58 DirectoryManager* dir_manager = user_share->dir_manager.get();
57 59
58 ScopedDirLookup dir(dir_manager, user_share->authenticated_name); 60 ScopedDirLookup dir(dir_manager, user_share->authenticated_name);
59 if (!dir.good()) 61 if (!dir.good())
60 return false; 62 return false;
61 63
62 std::string tag_name; 64 std::string tag_name;
63 switch (model_type) { 65 switch (model_type) {
64 case syncable::AUTOFILL: 66 case syncable::AUTOFILL:
65 tag_name = browser_sync::kAutofillTag; 67 tag_name = browser_sync::kAutofillTag;
66 break; 68 break;
67 case syncable::PREFERENCES: 69 case syncable::PREFERENCES:
68 tag_name = browser_sync::kPreferencesTag; 70 tag_name = browser_sync::kPreferencesTag;
69 break; 71 break;
70 case syncable::PASSWORDS: 72 case syncable::PASSWORDS:
71 tag_name = browser_sync::kPasswordTag; 73 tag_name = browser_sync::kPasswordTag;
72 break; 74 break;
73 case syncable::NIGORI: 75 case syncable::NIGORI:
74 tag_name = browser_sync::kNigoriTag; 76 tag_name = browser_sync::kNigoriTag;
75 break; 77 break;
76 case syncable::TYPED_URLS: 78 case syncable::TYPED_URLS:
77 tag_name = browser_sync::kTypedUrlTag; 79 tag_name = browser_sync::kTypedUrlTag;
78 break; 80 break;
79 case syncable::SESSIONS:
80 tag_name = browser_sync::kSessionsTag;
81 break;
82 default: 81 default:
83 return false; 82 return false;
84 } 83 }
85 84
86 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); 85 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__);
87 MutableEntry node(&wtrans, 86 MutableEntry node(&wtrans,
88 CREATE, 87 CREATE,
89 wtrans.root_id(), 88 wtrans.root_id(),
90 tag_name); 89 tag_name);
91 node.Put(UNIQUE_SERVER_TAG, tag_name); 90 node.Put(UNIQUE_SERVER_TAG, tag_name);
92 node.Put(IS_DIR, true); 91 node.Put(IS_DIR, true);
93 node.Put(SERVER_IS_DIR, false); 92 node.Put(SERVER_IS_DIR, false);
94 node.Put(IS_UNSYNCED, false); 93 node.Put(IS_UNSYNCED, false);
95 node.Put(IS_UNAPPLIED_UPDATE, false); 94 node.Put(IS_UNAPPLIED_UPDATE, false);
96 node.Put(SERVER_VERSION, 20); 95 node.Put(SERVER_VERSION, 20);
97 node.Put(BASE_VERSION, 20); 96 node.Put(BASE_VERSION, 20);
98 node.Put(IS_DEL, false); 97 node.Put(IS_DEL, false);
99 node.Put(syncable::ID, ids->MakeServer(tag_name)); 98 node.Put(ID, ids_.MakeServer(tag_name));
100 sync_pb::EntitySpecifics specifics; 99 sync_pb::EntitySpecifics specifics;
101 syncable::AddDefaultExtensionValue(model_type, &specifics); 100 syncable::AddDefaultExtensionValue(model_type, &specifics);
102 node.Put(SPECIFICS, specifics); 101 node.Put(SPECIFICS, specifics);
103 102
104 return true; 103 return true;
105 } 104 }
106 };
107
108 class AbstractProfileSyncServiceTest : public testing::Test {
109 public:
110 AbstractProfileSyncServiceTest()
111 : ui_thread_(ChromeThread::UI, &message_loop_) {}
112
113 bool CreateRoot(ModelType model_type) {
114 return ProfileSyncServiceTestHelper::CreateRoot(model_type,
115 service_.get(), &ids_);
116 }
117 105
118 protected: 106 protected:
119 107
120 MessageLoopForUI message_loop_; 108 MessageLoopForUI message_loop_;
121 ChromeThread ui_thread_; 109 ChromeThread ui_thread_;
122 ProfileSyncFactoryMock factory_; 110 ProfileSyncFactoryMock factory_;
123 scoped_ptr<TestProfileSyncService> service_; 111 scoped_ptr<TestProfileSyncService> service_;
124 TestIdFactory ids_; 112 TestIdFactory ids_;
125 }; 113 };
126 114
(...skipping 10 matching lines...) Expand all
137 125
138 bool success() { return success_; } 126 bool success() { return success_; }
139 127
140 private: 128 private:
141 AbstractProfileSyncServiceTest* test_; 129 AbstractProfileSyncServiceTest* test_;
142 ModelType model_type_; 130 ModelType model_type_;
143 bool success_; 131 bool success_;
144 }; 132 };
145 133
146 #endif // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ 134 #endif // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_restore_service.h ('k') | chrome/browser/sync/engine/syncapi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698