OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_PANELS_TEST_PANEL_NOTIFICATION_OBSERVER_H_ | |
6 #define CHROME_BROWSER_UI_PANELS_TEST_PANEL_NOTIFICATION_OBSERVER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "content/public/browser/notification_observer.h" | |
11 #include "content/public/browser/notification_registrar.h" | |
12 | |
13 namespace content { | |
14 class MessageLoopRunner; | |
15 class NotificationSource; | |
16 } | |
17 | |
18 // Common base class for a custom notification observer that waits | |
19 // on a notification until an expected state is achieved. | |
20 // Modeled after ui_test_utils notification observers, but can handle | |
21 // more than one occurrence of the notification. | |
22 class TestPanelNotificationObserver : public content::NotificationObserver { | |
23 public: | |
24 TestPanelNotificationObserver(int notification, | |
25 const content::NotificationSource& source); | |
26 ~TestPanelNotificationObserver() override; | |
27 | |
28 // Wait until the expected state is achieved. | |
29 void Wait(); | |
30 | |
31 // content::NotificationObserver: | |
32 void Observe(int type, | |
33 const content::NotificationSource& source, | |
34 const content::NotificationDetails& details) override; | |
35 | |
36 protected: | |
37 virtual bool AtExpectedState() = 0; | |
38 | |
39 bool seen_; // true after transition to expected state has been seen | |
40 bool running_; // indicates whether message loop is running | |
41 content::NotificationRegistrar registrar_; | |
42 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(TestPanelNotificationObserver); | |
45 }; | |
46 | |
47 #endif // CHROME_BROWSER_UI_PANELS_TEST_PANEL_NOTIFICATION_OBSERVER_H_ | |
OLD | NEW |