Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / lazy_background_page_test_util.h
blobba9e7f8435bde047244873028d6fdbf04e5e8478
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "content/public/browser/notification_service.h"
10 #include "content/public/test/test_utils.h"
12 // Helper class to wait for a lazy background page to load and close again.
13 class LazyBackgroundObserver {
14 public:
15 LazyBackgroundObserver()
16 : page_created_(extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY,
17 content::NotificationService::AllSources()),
18 page_closed_(extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
19 content::NotificationService::AllSources()) {}
20 explicit LazyBackgroundObserver(Profile* profile)
21 : page_created_(extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY,
22 content::NotificationService::AllSources()),
23 page_closed_(extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
24 content::Source<Profile>(profile)) {}
25 void Wait() {
26 page_created_.Wait();
27 page_closed_.Wait();
30 void WaitUntilLoaded() {
31 page_created_.Wait();
33 void WaitUntilClosed() {
34 page_closed_.Wait();
37 private:
38 content::WindowedNotificationObserver page_created_;
39 content::WindowedNotificationObserver page_closed_;
42 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_