| 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 #ifndef CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include "chrome/common/chrome_notification_types.h" |
| 8 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
| 9 #include "chrome/common/chrome_notification_types.h" | 10 #include "content/public/test/test_utils.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | |
| 11 | 11 |
| 12 // Helper class to wait for a lazy background page to load and close again. | 12 // Helper class to wait for a lazy background page to load and close again. |
| 13 class LazyBackgroundObserver { | 13 class LazyBackgroundObserver { |
| 14 public: | 14 public: |
| 15 LazyBackgroundObserver() | 15 LazyBackgroundObserver() |
| 16 : page_created_(chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 16 : page_created_(chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
| 17 content::NotificationService::AllSources()), | 17 content::NotificationService::AllSources()), |
| 18 page_closed_(chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 18 page_closed_(chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 19 content::NotificationService::AllSources()) { | 19 content::NotificationService::AllSources()) { |
| 20 } | 20 } |
| 21 explicit LazyBackgroundObserver(Profile* profile) | 21 explicit LazyBackgroundObserver(Profile* profile) |
| 22 : page_created_(chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 22 : page_created_(chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
| 23 content::NotificationService::AllSources()), | 23 content::NotificationService::AllSources()), |
| 24 page_closed_(chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 24 page_closed_(chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 25 content::Source<Profile>(profile)) { | 25 content::Source<Profile>(profile)) { |
| 26 } | 26 } |
| 27 void Wait() { | 27 void Wait() { |
| 28 page_created_.Wait(); | 28 page_created_.Wait(); |
| 29 page_closed_.Wait(); | 29 page_closed_.Wait(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void WaitUntilLoaded() { | 32 void WaitUntilLoaded() { |
| 33 page_created_.Wait(); | 33 page_created_.Wait(); |
| 34 } | 34 } |
| 35 void WaitUntilClosed() { | 35 void WaitUntilClosed() { |
| 36 page_closed_.Wait(); | 36 page_closed_.Wait(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 ui_test_utils::WindowedNotificationObserver page_created_; | 40 content::WindowedNotificationObserver page_created_; |
| 41 ui_test_utils::WindowedNotificationObserver page_closed_; | 41 content::WindowedNotificationObserver page_closed_; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_ | 44 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_PAGE_TEST_UTIL_H_ |
| OLD | NEW |