Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / ui / panels / test_panel_collection_squeeze_observer.cc
blobf64b52d6f3673a339ce8522a906ee947694ff555
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 #include "chrome/browser/ui/panels/test_panel_collection_squeeze_observer.h"
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/ui/panels/docked_panel_collection.h"
9 #include "chrome/browser/ui/panels/panel.h"
10 #include "content/public/browser/notification_source.h"
12 PanelCollectionSqueezeObserver::PanelCollectionSqueezeObserver(
13 DockedPanelCollection* collection, Panel* active_panel)
14 : TestPanelNotificationObserver(
15 chrome::NOTIFICATION_PANEL_COLLECTION_UPDATED,
16 content::Source<PanelCollection>(collection)),
17 panel_collection_(collection),
18 active_panel_(active_panel) {
21 PanelCollectionSqueezeObserver::~PanelCollectionSqueezeObserver() {}
23 bool PanelCollectionSqueezeObserver::IsSqueezed(Panel* panel) {
24 return panel->GetBounds().width() < panel->GetRestoredBounds().width();
27 bool PanelCollectionSqueezeObserver::AtExpectedState() {
28 const DockedPanelCollection::Panels& panels = panel_collection_->panels();
29 for (DockedPanelCollection::Panels::const_iterator iter = panels.begin();
30 iter != panels.end(); ++iter) {
31 if (*iter == active_panel_) {
32 if (IsSqueezed(*iter))
33 return false;
34 } else if (!IsSqueezed(*iter)) {
35 return false;
38 return true;