Index: chrome/browser/sync/test/integration/apps_helper.cc |
diff --git a/chrome/browser/sync/test/integration/apps_helper.cc b/chrome/browser/sync/test/integration/apps_helper.cc |
index fe9a37977afb1f9f34099924ee0d1042122c5311..77c83c9f6b419cc7911d47e288609899d6f43393 100644 |
--- a/chrome/browser/sync/test/integration/apps_helper.cc |
+++ b/chrome/browser/sync/test/integration/apps_helper.cc |
@@ -6,11 +6,14 @@ |
#include "base/logging.h" |
#include "base/string_number_conversions.h" |
+#include "chrome/browser/extensions/extension_process_manager.h" |
+#include "chrome/browser/extensions/extension_system.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/sync/test/integration/sync_app_helper.h" |
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
#include "chrome/browser/sync/test/integration/sync_extension_helper.h" |
#include "chrome/common/extensions/extension.h" |
+#include "content/public/test/test_utils.h" |
using sync_datatype_helper::test; |
@@ -20,6 +23,19 @@ std::string CreateFakeAppName(int index) { |
return "fakeapp" + base::IntToString(index); |
} |
+void WaitForPlatformAppsToUnloadForProfile(Profile* profile) { |
+ // Note this will hang if there are extensions with persistent background |
+ // pages loaded. |
+ ExtensionProcessManager* pm = |
+ extensions::ExtensionSystem::Get(profile)->process_manager(); |
+ while (!pm->background_hosts().empty()) { |
+ content::WindowedNotificationObserver destroyed_observer( |
+ chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
+ content::NotificationService::AllSources()); |
+ destroyed_observer.Wait(); |
+ } |
+} |
+ |
} // namespace |
namespace apps_helper { |
@@ -126,4 +142,13 @@ void FixNTPOrdinalCollisions(Profile* profile) { |
SyncAppHelper::GetInstance()->FixNTPOrdinalCollisions(profile); |
} |
+void WaitForPlatformAppsToUnload() { |
+ // First run any pending tasks to allow any about to load background |
+ // pages to load. |
+ MessageLoop::current()->RunUntilIdle(); |
+ for (int i = 0; i < test()->num_clients(); ++i) |
+ WaitForPlatformAppsToUnloadForProfile(test()->GetProfile(i)); |
+ WaitForPlatformAppsToUnloadForProfile(test()->verifier()); |
+} |
+ |
} // namespace apps_helper |