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

Unified Diff: ash/wm/window_positioner_unittest.cc

Issue 55303006: Make sure the non browser/non app widget is fully visible when created on ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/window_positioner.cc ('k') | ash/wm/window_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_positioner_unittest.cc
diff --git a/ash/wm/window_positioner_unittest.cc b/ash/wm/window_positioner_unittest.cc
index 497e01490b1f0e7d1e564b317f032123adf64266..fb41626e84246e045a4cb7899c97d8f0656392a4 100644
--- a/ash/wm/window_positioner_unittest.cc
+++ b/ash/wm/window_positioner_unittest.cc
@@ -11,6 +11,7 @@
#include "ui/aura/root_window.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
namespace ash {
@@ -49,4 +50,54 @@ TEST_F(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) {
second_root_window).bounds().Contains(bounds));
}
+namespace {
+
+// A WidgetDelegate that returns the out of display saved bounds.
+class OutOfDisplayDelegate : public views::WidgetDelegate {
+ public:
+ explicit OutOfDisplayDelegate(views::Widget* widget) : widget_(widget) {}
+ virtual ~OutOfDisplayDelegate() {}
+
+ // Overridden from WidgetDelegate:
+ virtual void DeleteDelegate() OVERRIDE {
+ delete this;
+ }
+ virtual views::Widget* GetWidget() OVERRIDE {
+ return widget_;
+ }
+ virtual const views::Widget* GetWidget() const OVERRIDE {
+ return widget_;
+ }
+ virtual bool GetSavedWindowPlacement(
+ const views::Widget* widget,
+ gfx::Rect* bounds,
+ ui::WindowShowState* show_state) const OVERRIDE {
+ bounds->SetRect(450, 10, 100, 100);
+ *show_state = ui::SHOW_STATE_NORMAL;
+ return true;
+ }
+
+ private:
+ views::Widget* widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(OutOfDisplayDelegate);
+};
+
+} // namespace
+
+TEST_F(WindowPositionerTest, EnsureMinimumVisibility) {
+ UpdateDisplay("400x400");
+ views::Widget* widget = new views::Widget();
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.delegate = new OutOfDisplayDelegate(widget);
+ params.context = Shell::GetPrimaryRootWindow();
+ widget->Init(params);
+ widget->SetBounds(gfx::Rect(450,10, 100, 100));
+ wm::GetWindowState(widget->GetNativeView())->set_minimum_visibility(true);
+ widget->Show();
+ // Make sure the bounds is adjusted to be inside the work area.
+ EXPECT_EQ("390,10 100x100", widget->GetWindowBoundsInScreen().ToString());
+ widget->CloseNow();
+}
+
} // namespace
« no previous file with comments | « ash/wm/window_positioner.cc ('k') | ash/wm/window_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698