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_collection_squeeze_observer.h" 6 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" 11 PanelCollectionSqueezeObserver(DockedPanelCollection * collection,Panel * active_panel)12PanelCollectionSqueezeObserver::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) { 19 } 20 ~PanelCollectionSqueezeObserver()21PanelCollectionSqueezeObserver::~PanelCollectionSqueezeObserver() {} 22 IsSqueezed(Panel * panel)23bool PanelCollectionSqueezeObserver::IsSqueezed(Panel* panel) { 24 return panel->GetBounds().width() < panel->GetRestoredBounds().width(); 25 } 26 AtExpectedState()27bool 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; 36 } 37 } 38 return true; 39 } 40