| 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_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_ | 6 #define CHROME_BROWSER_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "chrome/test/base/ui_test_utils.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "content/public/browser/notification_observer.h" |
| 10 #include "content/public/browser/notification_registrar.h" |
| 9 | 11 |
| 10 class Panel; | 12 class Panel; |
| 11 | 13 |
| 14 namespace content { |
| 15 class MessageLoopRunner; |
| 16 } |
| 17 |
| 12 // Custom notification observer for waiting on panel active state. | 18 // Custom notification observer for waiting on panel active state. |
| 13 // Modeled after ui_test_utils notification observers. | 19 // Modeled after ui_test_utils notification observers. |
| 14 class PanelActiveStateObserver : public content::NotificationObserver { | 20 class PanelActiveStateObserver : public content::NotificationObserver { |
| 15 public: | 21 public: |
| 16 // Register to listen for panel active state change notifications | 22 // Register to listen for panel active state change notifications |
| 17 // for the specified panel to detect a change to the expected active | 23 // for the specified panel to detect a change to the expected active |
| 18 // state. | 24 // state. |
| 19 PanelActiveStateObserver(Panel* panel, bool expect_active); | 25 PanelActiveStateObserver(Panel* panel, bool expect_active); |
| 20 virtual ~PanelActiveStateObserver(); | 26 virtual ~PanelActiveStateObserver(); |
| 21 | 27 |
| 22 // Wait until the active state has changed to the expected state. | 28 // Wait until the active state has changed to the expected state. |
| 23 void Wait(); | 29 void Wait(); |
| 24 | 30 |
| 25 // content::NotificationObserver: | 31 // content::NotificationObserver: |
| 26 virtual void Observe(int type, | 32 virtual void Observe(int type, |
| 27 const content::NotificationSource& source, | 33 const content::NotificationSource& source, |
| 28 const content::NotificationDetails& details) OVERRIDE; | 34 const content::NotificationDetails& details) OVERRIDE; |
| 29 | 35 |
| 30 private: | 36 private: |
| 31 bool AtExpectedState(); | 37 bool AtExpectedState(); |
| 32 Panel* panel_; | 38 Panel* panel_; |
| 33 bool expect_active_; | 39 bool expect_active_; |
| 34 bool seen_; // true after transition to expected state has been seen | 40 bool seen_; // true after transition to expected state has been seen |
| 35 bool running_; // indicates whether message loop is running | 41 bool running_; // indicates whether message loop is running |
| 36 content::NotificationRegistrar registrar_; | 42 content::NotificationRegistrar registrar_; |
| 37 scoped_refptr<ui_test_utils::MessageLoopRunner> message_loop_runner_; | 43 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 38 | 44 |
| 39 DISALLOW_COPY_AND_ASSIGN(PanelActiveStateObserver); | 45 DISALLOW_COPY_AND_ASSIGN(PanelActiveStateObserver); |
| 40 }; | 46 }; |
| 41 | 47 |
| 42 #endif // CHROME_BROWSER_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_ | 48 #endif // CHROME_BROWSER_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_ |
| OLD | NEW |