Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / panels / test_panel_notification_observer.h
blobcc070804f34f4d7017f6b7aa4005949f074c297a
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"
12 namespace content {
13 class MessageLoopRunner;
14 class NotificationSource;
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 {
22 public:
23 TestPanelNotificationObserver(int notification,
24 const content::NotificationSource& source);
25 ~TestPanelNotificationObserver() override;
27 // Wait until the expected state is achieved.
28 void Wait();
30 // content::NotificationObserver:
31 void Observe(int type,
32 const content::NotificationSource& source,
33 const content::NotificationDetails& details) override;
35 protected:
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_