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

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

Issue 1834323004: [Sync] Eliminate verifier profile from sync_integration_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix failing tests 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 std::vector<Profile*> profiles = test_->GetAllProfiles();
43 for (int i = 0; i < test->num_clients(); ++i) { 43 for (std::vector<Profile*>::iterator it = profiles.begin();
44 extensions::ExtensionSystem::Get(test_->GetProfile(i)) 44 it != profiles.end();
45 ->InitForRegularProfile(true); 45 ++it) {
46 extensions::ExtensionSystem::Get(*it)->InitForRegularProfile(true);
46 } 47 }
47 extensions::ExtensionSystem::Get(test_->verifier())
48 ->InitForRegularProfile(true);
49 48
50 setup_completed_ = true; 49 setup_completed_ = true;
51 } 50 }
52 51
53 bool SyncAppListHelper::AppListMatchesVerifier(Profile* profile) { 52 bool SyncAppListHelper::AppListMatch(Profile* profile1, Profile* profile2) {
54 AppListSyncableService* service = 53 AppListSyncableService* service1 =
55 AppListSyncableServiceFactory::GetForProfile(profile); 54 AppListSyncableServiceFactory::GetForProfile(profile1);
56 AppListSyncableService* verifier = 55 AppListSyncableService* service2 =
57 AppListSyncableServiceFactory::GetForProfile(test_->verifier()); 56 AppListSyncableServiceFactory::GetForProfile(profile2);
58 // Note: sync item entries may not exist in verifier, but item lists should 57 // Note: sync item entries may not exist in verifier, but item lists should
59 // match. 58 // match.
60 if (service->GetModel()->top_level_item_list()->item_count() != 59 if (service1->GetModel()->top_level_item_list()->item_count() !=
61 verifier->GetModel()->top_level_item_list()->item_count()) { 60 service2->GetModel()->top_level_item_list()->item_count()) {
62 LOG(ERROR) << "Model item count: " 61 LOG(ERROR) << "Model item count: "
63 << service->GetModel()->top_level_item_list()->item_count() 62 << service1->GetModel()->top_level_item_list()->item_count()
64 << " != " 63 << " != "
65 << verifier->GetModel()->top_level_item_list()->item_count(); 64 << service2->GetModel()->top_level_item_list()->item_count();
66 return false; 65 return false;
67 } 66 }
68 bool res = true; 67 bool res = true;
69 for (size_t i = 0; 68 for (size_t i = 0;
70 i < service->GetModel()->top_level_item_list()->item_count(); ++i) { 69 i < service1->GetModel()->top_level_item_list()->item_count(); ++i) {
71 AppListItem* item1 = service->GetModel()->top_level_item_list()->item_at(i); 70 AppListItem* item1 =
71 service1->GetModel()->top_level_item_list()->item_at(i);
72 AppListItem* item2 = 72 AppListItem* item2 =
73 verifier->GetModel()->top_level_item_list()->item_at(i); 73 service2->GetModel()->top_level_item_list()->item_at(i);
74 if (item1->CompareForTest(item2)) 74 if (item1->CompareForTest(item2))
75 continue; 75 continue;
76 76
77 LOG(ERROR) << "Item(" << i << "): " << item1->ToDebugString() 77 LOG(ERROR) << "Item(" << i << "): " << item1->ToDebugString()
78 << " != " << item2->ToDebugString(); 78 << " != " << item2->ToDebugString();
79 size_t index2; 79 size_t index2;
80 if (!verifier->GetModel()->top_level_item_list()->FindItemIndex(item1->id(), 80 if (!service2->GetModel()->top_level_item_list()->FindItemIndex(item1->id(),
81 &index2)) { 81 &index2)) {
82 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString() 82 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString()
83 << " Not in verifier."; 83 << " Not in profile2.";
84 } else { 84 } else {
85 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString() 85 LOG(ERROR) << " Item(" << i << "): " << item1->ToDebugString()
86 << " Has different verifier index: " << index2; 86 << " Has different profile2 index: " << index2;
87 item2 = verifier->GetModel()->top_level_item_list()->item_at(index2); 87 item2 = service2->GetModel()->top_level_item_list()->item_at(index2);
88 LOG(ERROR) << " Verifier Item(" << index2 88 LOG(ERROR) << " profile2 Item(" << index2
89 << "): " << item2->ToDebugString(); 89 << "): " << item2->ToDebugString();
90 } 90 }
91 res = false; 91 res = false;
92 } 92 }
93 return res; 93 return res;
94 } 94 }
95 95
96 bool SyncAppListHelper::AllProfilesHaveSameAppListAsVerifier() { 96 bool SyncAppListHelper::AllProfilesHaveSameAppList() {
97 bool res = true; 97 std::vector<Profile*> profiles = test_->GetAllProfiles();
98 for (int i = 0; i < test_->num_clients(); ++i) { 98 std::vector<Profile*>::iterator it = profiles.begin();
99 if (!AppListMatchesVerifier(test_->GetProfile(i))) { 99 Profile* profile1 = *it;
Nicolas Zea 2016/03/31 19:01:22 same comment about moving into for loop
shadi 2016/03/31 22:46:47 Done.
100 LOG(ERROR) << "Profile " << i 100 ++it;
101 << " doesn't have the same app list as the verifier profile."; 101 for (; it != profiles.end(); ++it) {
102 res = false; 102 if (!AppListMatch(profile1, *it)) {
103 DVLOG(1) << "Profile1: "
104 << AppListSyncableServiceFactory::GetForProfile(profile1);
105 PrintAppList(profile1);
106 DVLOG(1) << "Profile2: "
107 << AppListSyncableServiceFactory::GetForProfile(*it);
108 PrintAppList(*it);
109 return false;
103 } 110 }
104 } 111 }
105 if (!res) { 112 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 } 113 }
119 114
120 void SyncAppListHelper::MoveApp(Profile* profile, size_t from, size_t to) { 115 void SyncAppListHelper::MoveApp(Profile* profile, size_t from, size_t to) {
121 AppListSyncableService* service = 116 AppListSyncableService* service =
122 AppListSyncableServiceFactory::GetForProfile(profile); 117 AppListSyncableServiceFactory::GetForProfile(profile);
123 service->GetModel()->top_level_item_list()->MoveItem(from, to); 118 service->GetModel()->top_level_item_list()->MoveItem(from, to);
124 } 119 }
125 120
126 void SyncAppListHelper::MoveAppToFolder(Profile* profile, 121 void SyncAppListHelper::MoveAppToFolder(Profile* profile,
127 size_t index, 122 size_t index,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 base::StringPrintf(" Folder Item(%d): ", static_cast<int>(i)); 178 base::StringPrintf(" Folder Item(%d): ", static_cast<int>(i));
184 PrintItem(profile, child, child_label); 179 PrintItem(profile, child, child_label);
185 } 180 }
186 return; 181 return;
187 } 182 }
188 DVLOG(1) << label << item->ToDebugString() 183 DVLOG(1) << label << item->ToDebugString()
189 << " Page: " << s->GetPageOrdinal(id).ToDebugString().substr(0, 8) 184 << " Page: " << s->GetPageOrdinal(id).ToDebugString().substr(0, 8)
190 << " Item: " 185 << " Item: "
191 << s->GetAppLaunchOrdinal(id).ToDebugString().substr(0, 8); 186 << s->GetAppLaunchOrdinal(id).ToDebugString().substr(0, 8);
192 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698