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

Side by Side Diff: chrome/browser/sync/test/integration/sync_app_list_helper.cc

Issue 1851243002: [Sync] Eliminate verifier profile from sync_integration_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not remove AwaitQuiescence() Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/sync/test/integration/sync_app_list_helper.h" 5 #include "chrome/browser/sync/test/integration/sync_app_list_helper.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 9 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
10 #include "chrome/browser/sync/test/integration/sync_test.h" 10 #include "chrome/browser/sync/test/integration/sync_test.h"
(...skipping 21 matching lines...) Expand all
32 SyncAppListHelper::SyncAppListHelper() : test_(NULL), setup_completed_(false) {} 32 SyncAppListHelper::SyncAppListHelper() : test_(NULL), setup_completed_(false) {}
33 33
34 SyncAppListHelper::~SyncAppListHelper() {} 34 SyncAppListHelper::~SyncAppListHelper() {}
35 35
36 void SyncAppListHelper::SetupIfNecessary(SyncTest* test) { 36 void SyncAppListHelper::SetupIfNecessary(SyncTest* test) {
37 if (setup_completed_) { 37 if (setup_completed_) {
38 DCHECK_EQ(test, test_); 38 DCHECK_EQ(test, test_);
39 return; 39 return;
40 } 40 }
41 test_ = test; 41 test_ = test;
42 42 for (auto* profile : test_->GetAllProfiles()) {
43 for (int i = 0; i < test->num_clients(); ++i) { 43 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile(true);
44 extensions::ExtensionSystem::Get(test_->GetProfile(i))
45 ->InitForRegularProfile(true);
46 } 44 }
47 extensions::ExtensionSystem::Get(test_->verifier())
48 ->InitForRegularProfile(true);
49 45
50 setup_completed_ = true; 46 setup_completed_ = true;
51 } 47 }
52 48
53 bool SyncAppListHelper::AppListMatchesVerifier(Profile* profile) { 49 bool SyncAppListHelper::AppListMatch(Profile* profile1, Profile* profile2) {
54 AppListSyncableService* service = 50 AppListSyncableService* service1 =
55 AppListSyncableServiceFactory::GetForProfile(profile); 51 AppListSyncableServiceFactory::GetForProfile(profile1);
56 AppListSyncableService* verifier = 52 AppListSyncableService* service2 =
57 AppListSyncableServiceFactory::GetForProfile(test_->verifier()); 53 AppListSyncableServiceFactory::GetForProfile(profile2);
58 // Note: sync item entries may not exist in verifier, but item lists should 54 // Note: sync item entries may not exist in verifier, but item lists should
59 // match. 55 // match.
60 if (service->GetModel()->top_level_item_list()->item_count() != 56 if (service1->GetModel()->top_level_item_list()->item_count() !=
61 verifier->GetModel()->top_level_item_list()->item_count()) { 57 service2->GetModel()->top_level_item_list()->item_count()) {
62 LOG(ERROR) << "Model item count: " 58 LOG(ERROR) << "Model item count: "
63 << service->GetModel()->top_level_item_list()->item_count() 59 << service1->GetModel()->top_level_item_list()->item_count()
64 << " != " 60 << " != "
65 << verifier->GetModel()->top_level_item_list()->item_count(); 61 << service2->GetModel()->top_level_item_list()->item_count();
66 return false; 62 return false;
67 } 63 }
68 bool res = true; 64 bool res = true;
69 for (size_t i = 0; 65 for (size_t i = 0;
70 i < service->GetModel()->top_level_item_list()->item_count(); ++i) { 66 i < service1->GetModel()->top_level_item_list()->item_count(); ++i) {
71 AppListItem* item1 = service->GetModel()->top_level_item_list()->item_at(i); 67 AppListItem* item1 =
68 service1->GetModel()->top_level_item_list()->item_at(i);
72 AppListItem* item2 = 69 AppListItem* item2 =
73 verifier->GetModel()->top_level_item_list()->item_at(i); 70 service2->GetModel()->top_level_item_list()->item_at(i);
74 if (item1->CompareForTest(item2)) 71 if (item1->CompareForTest(item2))
75 continue; 72 continue;
76 73
77 LOG(ERROR) << "Item(" << i << "): " << item1->ToDebugString() 74 LOG(ERROR) << "Item(" << i << "): " << item1->ToDebugString()
78 << " != " << item2->ToDebugString(); 75 << " != " << item2->ToDebugString();
79 size_t index2; 76 size_t index2;
80 if (!verifier->GetModel()->top_level_item_list()->FindItemIndex(item1->id(), 77 if (!service2->GetModel()->top_level_item_list()->FindItemIndex(item1->id(),
81 &index2)) { 78 &index2)) {
82 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString() 79 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString()
83 << " Not in verifier."; 80 << " Not in profile2.";
84 } else { 81 } else {
85 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString() 82 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString()
86 << " Has different verifier index: " << index2; 83 << " Has different profile2 index: " << index2;
87 item2 = verifier->GetModel()->top_level_item_list()->item_at(index2); 84 item2 = service2->GetModel()->top_level_item_list()->item_at(index2);
88 LOG(ERROR) << " Verifier Item(" << index2 85 LOG(ERROR) << " profile2 Item(" << index2
89 << "): " << item2->ToDebugString(); 86 << "): " << item2->ToDebugString();
90 } 87 }
91 res = false; 88 res = false;
92 } 89 }
93 return res; 90 return res;
94 } 91 }
95 92
96 bool SyncAppListHelper::AllProfilesHaveSameAppListAsVerifier() { 93 bool SyncAppListHelper::AllProfilesHaveSameAppList() {
97 bool res = true; 94 const auto& profiles = test_->GetAllProfiles();
98 for (int i = 0; i < test_->num_clients(); ++i) { 95 for (auto* profile : profiles) {
99 if (!AppListMatchesVerifier(test_->GetProfile(i))) { 96 if (profile != profiles.front() &&
100 LOG(ERROR) << "Profile " << i 97 !AppListMatch(profiles.front(), profile)) {
101 << " doesn't have the same app list as the verifier profile."; 98 DVLOG(1) << "Profile1: "
102 res = false; 99 << AppListSyncableServiceFactory::GetForProfile(profile);
100 PrintAppList(profile);
101 DVLOG(1) << "Profile2: " <<
102 AppListSyncableServiceFactory::GetForProfile(profiles.front());
103 PrintAppList(profiles.front());
104 return false;
103 } 105 }
104 } 106 }
105 if (!res) { 107 return true;
106 Profile* verifier = test_->verifier();
107 DVLOG(1) << "Verifier: "
108 << AppListSyncableServiceFactory::GetForProfile(verifier);
109 PrintAppList(test_->verifier());
110 for (int i = 0; i < test_->num_clients(); ++i) {
111 Profile* profile = test_->GetProfile(i);
112 DVLOG(1) << "Profile: " << i << ": "
113 << AppListSyncableServiceFactory::GetForProfile(profile);
114 PrintAppList(profile);
115 }
116 }
117 return res;
118 } 108 }
119 109
120 void SyncAppListHelper::MoveApp(Profile* profile, size_t from, size_t to) { 110 void SyncAppListHelper::MoveApp(Profile* profile, size_t from, size_t to) {
121 AppListSyncableService* service = 111 AppListSyncableService* service =
122 AppListSyncableServiceFactory::GetForProfile(profile); 112 AppListSyncableServiceFactory::GetForProfile(profile);
123 service->GetModel()->top_level_item_list()->MoveItem(from, to); 113 service->GetModel()->top_level_item_list()->MoveItem(from, to);
124 } 114 }
125 115
126 void SyncAppListHelper::MoveAppToFolder(Profile* profile, 116 void SyncAppListHelper::MoveAppToFolder(Profile* profile,
127 size_t index, 117 size_t index,
(...skipping 11 matching lines...) Expand all
139 AppListSyncableServiceFactory::GetForProfile(profile); 129 AppListSyncableServiceFactory::GetForProfile(profile);
140 AppListFolderItem* folder = service->GetModel()->FindFolderItem(folder_id); 130 AppListFolderItem* folder = service->GetModel()->FindFolderItem(folder_id);
141 if (!folder) { 131 if (!folder) {
142 LOG(ERROR) << "Folder not found: " << folder_id; 132 LOG(ERROR) << "Folder not found: " << folder_id;
143 return; 133 return;
144 } 134 }
145 service->GetModel()->MoveItemToFolder( 135 service->GetModel()->MoveItemToFolder(
146 folder->item_list()->item_at(index_in_folder), ""); 136 folder->item_list()->item_at(index_in_folder), "");
147 } 137 }
148 138
149 void SyncAppListHelper::CopyOrdinalsToVerifier(Profile* profile,
150 const std::string& id) {
151 AppListSyncableService* service =
152 AppListSyncableServiceFactory::GetForProfile(profile);
153 AppListSyncableService* verifier =
154 AppListSyncableServiceFactory::GetForProfile(test_->verifier());
155 verifier->GetModel()->top_level_item_list()->SetItemPosition(
156 verifier->GetModel()->FindItem(id),
157 service->GetModel()->FindItem(id)->position());
158 }
159
160 void SyncAppListHelper::PrintAppList(Profile* profile) { 139 void SyncAppListHelper::PrintAppList(Profile* profile) {
161 AppListSyncableService* service = 140 AppListSyncableService* service =
162 AppListSyncableServiceFactory::GetForProfile(profile); 141 AppListSyncableServiceFactory::GetForProfile(profile);
163 for (size_t i = 0; 142 for (size_t i = 0;
164 i < service->GetModel()->top_level_item_list()->item_count(); ++i) { 143 i < service->GetModel()->top_level_item_list()->item_count(); ++i) {
165 AppListItem* item = service->GetModel()->top_level_item_list()->item_at(i); 144 AppListItem* item = service->GetModel()->top_level_item_list()->item_at(i);
166 std::string label = base::StringPrintf("Item(%d): ", static_cast<int>(i)); 145 std::string label = base::StringPrintf("Item(%d): ", static_cast<int>(i));
167 PrintItem(profile, item, label); 146 PrintItem(profile, item, label);
168 } 147 }
169 } 148 }
(...skipping 13 matching lines...) Expand all
183 base::StringPrintf(" Folder Item(%d): ", static_cast<int>(i)); 162 base::StringPrintf(" Folder Item(%d): ", static_cast<int>(i));
184 PrintItem(profile, child, child_label); 163 PrintItem(profile, child, child_label);
185 } 164 }
186 return; 165 return;
187 } 166 }
188 DVLOG(1) << label << item->ToDebugString() 167 DVLOG(1) << label << item->ToDebugString()
189 << " Page: " << s->GetPageOrdinal(id).ToDebugString().substr(0, 8) 168 << " Page: " << s->GetPageOrdinal(id).ToDebugString().substr(0, 8)
190 << " Item: " 169 << " Item: "
191 << s->GetAppLaunchOrdinal(id).ToDebugString().substr(0, 8); 170 << s->GetAppLaunchOrdinal(id).ToDebugString().substr(0, 8);
192 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_app_list_helper.h ('k') | chrome/browser/sync/test/integration/sync_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698