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