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

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

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