OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/apps_helper.h" | 5 #include "chrome/browser/sync/test/integration/apps_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "chrome/browser/extensions/extension_process_manager.h" | |
10 #include "chrome/browser/extensions/extension_system.h" | |
11 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/sync/test/integration/sync_app_helper.h" | 10 #include "chrome/browser/sync/test/integration/sync_app_helper.h" |
13 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 11 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
14 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" | 12 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" |
15 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
16 #include "content/public/test/test_utils.h" | |
17 | 14 |
18 using sync_datatype_helper::test; | 15 using sync_datatype_helper::test; |
19 | 16 |
20 namespace { | 17 namespace { |
21 | 18 |
22 std::string CreateFakeAppName(int index) { | 19 std::string CreateFakeAppName(int index) { |
23 return "fakeapp" + base::IntToString(index); | 20 return "fakeapp" + base::IntToString(index); |
24 } | 21 } |
25 | 22 |
26 void WaitForPlatformAppsToUnloadForProfile(Profile* profile) { | |
27 // Note this will hang if there are extensions with persistent background | |
28 // pages loaded. | |
29 ExtensionProcessManager* pm = | |
30 extensions::ExtensionSystem::Get(profile)->process_manager(); | |
31 while (!pm->background_hosts().empty()) { | |
32 content::WindowedNotificationObserver destroyed_observer( | |
33 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | |
34 content::NotificationService::AllSources()); | |
35 destroyed_observer.Wait(); | |
36 } | |
37 } | |
38 | |
39 } // namespace | 23 } // namespace |
40 | 24 |
41 namespace apps_helper { | 25 namespace apps_helper { |
42 | 26 |
43 bool HasSameAppsAsVerifier(int index) { | 27 bool HasSameAppsAsVerifier(int index) { |
44 return SyncAppHelper::GetInstance()->AppStatesMatch( | 28 return SyncAppHelper::GetInstance()->AppStatesMatch( |
45 test()->GetProfile(index), test()->verifier()); | 29 test()->GetProfile(index), test()->verifier()); |
46 } | 30 } |
47 | 31 |
48 bool AllProfilesHaveSameAppsAsVerifier() { | 32 bool AllProfilesHaveSameAppsAsVerifier() { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void CopyNTPOrdinals(Profile* source, Profile* destination, int index) { | 119 void CopyNTPOrdinals(Profile* source, Profile* destination, int index) { |
136 SetPageOrdinalForApp(destination, index, GetPageOrdinalForApp(source, index)); | 120 SetPageOrdinalForApp(destination, index, GetPageOrdinalForApp(source, index)); |
137 SetAppLaunchOrdinalForApp( | 121 SetAppLaunchOrdinalForApp( |
138 destination, index, GetAppLaunchOrdinalForApp(source, index)); | 122 destination, index, GetAppLaunchOrdinalForApp(source, index)); |
139 } | 123 } |
140 | 124 |
141 void FixNTPOrdinalCollisions(Profile* profile) { | 125 void FixNTPOrdinalCollisions(Profile* profile) { |
142 SyncAppHelper::GetInstance()->FixNTPOrdinalCollisions(profile); | 126 SyncAppHelper::GetInstance()->FixNTPOrdinalCollisions(profile); |
143 } | 127 } |
144 | 128 |
145 void WaitForPlatformAppsToUnload() { | |
146 // First run any pending tasks to allow any about to load background | |
147 // pages to load. | |
148 MessageLoop::current()->RunUntilIdle(); | |
149 for (int i = 0; i < test()->num_clients(); ++i) | |
150 WaitForPlatformAppsToUnloadForProfile(test()->GetProfile(i)); | |
151 WaitForPlatformAppsToUnloadForProfile(test()->verifier()); | |
152 } | |
153 | |
154 } // namespace apps_helper | 129 } // namespace apps_helper |
OLD | NEW |