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

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

Issue 10689082: Fix flaky linux panel tests related to active state checks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove log msg Created 8 years, 5 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
« no previous file with comments | « chrome/browser/ui/panels/test_panel_active_state_observer.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "chrome/browser/ui/panels/test_panel_active_state_observer.h"
6
7 #include "chrome/browser/ui/panels/panel.h"
8 #include "chrome/common/chrome_notification_types.h"
9
10 PanelActiveStateObserver::PanelActiveStateObserver(
11 Panel* panel,
12 bool expect_active)
13 : panel_(panel),
14 expect_active_(expect_active),
15 seen_(false),
16 running_(false) {
17 registrar_.Add(this, chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS,
18 content::Source<Panel>(panel));
19 }
20
21 PanelActiveStateObserver::~PanelActiveStateObserver() {}
22
23 void PanelActiveStateObserver::Wait() {
24 if (seen_ || AtExpectedState())
25 return;
26
27 running_ = true;
28 message_loop_runner_ = new ui_test_utils::MessageLoopRunner;
29 message_loop_runner_->Run();
30 EXPECT_TRUE(seen_);
31 }
32
33 bool PanelActiveStateObserver::AtExpectedState() {
34 return panel_->IsActive() == expect_active_;
35 }
36
37 void PanelActiveStateObserver::Observe(
38 int type,
39 const content::NotificationSource& source,
40 const content::NotificationDetails& details) {
41 if (!running_)
42 return;
43
44 if (AtExpectedState()) {
45 seen_ = true;
46 message_loop_runner_->Quit();
47 running_ = false;
48 }
49 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/test_panel_active_state_observer.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698