Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/browser/ui/panels/test_panel_active_state_observer.h

Issue 10914242: Improve panel tests by properly waiting for expected conditions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/memory/ref_counted.h" 8 #include "chrome/browser/ui/panels/test_panel_notification_observer.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
11 9
12 class Panel; 10 class Panel;
13 11
14 namespace content {
15 class MessageLoopRunner;
16 }
17
18 // Custom notification observer for waiting on panel active state. 12 // Custom notification observer for waiting on panel active state.
19 // Modeled after ui_test_utils notification observers. 13 // Modeled after ui_test_utils notification observers.
20 class PanelActiveStateObserver : public content::NotificationObserver { 14 class PanelActiveStateObserver : public TestPanelNotificationObserver {
21 public: 15 public:
22 // Register to listen for panel active state change notifications 16 // Register to listen for panel active state change notifications
23 // for the specified panel to detect a change to the expected active 17 // for the specified panel to detect a change to the expected active
24 // state. 18 // state.
25 PanelActiveStateObserver(Panel* panel, bool expect_active); 19 PanelActiveStateObserver(Panel* panel, bool expect_active);
26 virtual ~PanelActiveStateObserver(); 20 virtual ~PanelActiveStateObserver();
27 21
28 // Wait until the active state has changed to the expected state. 22 private:
29 void Wait(); 23 // TestNotificationObserver override:
24 virtual bool AtExpectedState() OVERRIDE;
30 25
31 // content::NotificationObserver:
32 virtual void Observe(int type,
33 const content::NotificationSource& source,
34 const content::NotificationDetails& details) OVERRIDE;
35
36 private:
37 bool AtExpectedState();
38 Panel* panel_; 26 Panel* panel_;
39 bool expect_active_; 27 bool expect_active_;
40 bool seen_; // true after transition to expected state has been seen
41 bool running_; // indicates whether message loop is running
42 content::NotificationRegistrar registrar_;
43 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
44 28
45 DISALLOW_COPY_AND_ASSIGN(PanelActiveStateObserver); 29 DISALLOW_COPY_AND_ASSIGN(PanelActiveStateObserver);
46 }; 30 };
47 31
48 #endif // CHROME_BROWSER_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_ 32 #endif // CHROME_BROWSER_UI_PANELS_TEST_PANEL_ACTIVE_STATE_OBSERVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_gtk.cc ('k') | chrome/browser/ui/panels/test_panel_active_state_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698