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

Unified Diff: ui/aura_shell/toplevel_window_event_filter_unittest.cc

Issue 8618009: Aura: Fix window resizing for large drags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix HtmlDialogBrowserTest Created 9 years, 1 month 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 | « ui/aura_shell/toplevel_window_event_filter.cc ('k') | ui/views/widget/native_widget_aura.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/toplevel_window_event_filter_unittest.cc
diff --git a/ui/aura_shell/toplevel_window_event_filter_unittest.cc b/ui/aura_shell/toplevel_window_event_filter_unittest.cc
index e2c009428ec215df8fb71c950d5af63ed10bb86d..a2c0eed3dea588c8b670492317018f7ef3818fd3 100644
--- a/ui/aura_shell/toplevel_window_event_filter_unittest.cc
+++ b/ui/aura_shell/toplevel_window_event_filter_unittest.cc
@@ -43,13 +43,8 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate {
private:
// Overridden from aura::Test::TestWindowDelegate:
- virtual void OnBoundsChanging(gfx::Rect* new_bounds) OVERRIDE {
- if (!min_size_.IsEmpty()) {
- new_bounds->set_width(std::max(min_size_.width(),
- new_bounds->width()));
- new_bounds->set_height(std::max(min_size_.height(),
- new_bounds->height()));
- }
+ virtual gfx::Size GetMinimumSize() const OVERRIDE {
+ return min_size_;
}
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE {
return hittest_code_;
@@ -126,7 +121,7 @@ TEST_F(ToplevelWindowEventFilterTest, GrowBox) {
scoped_ptr<aura::Window> w1(CreateWindow(HTGROWBOX));
TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate());
- window_delegate->set_min_size(gfx::Size(50, 50));
+ window_delegate->set_min_size(gfx::Size(40, 40));
gfx::Point position = w1->bounds().origin();
aura::test::EventGenerator generator;
@@ -147,7 +142,7 @@ TEST_F(ToplevelWindowEventFilterTest, GrowBox) {
// Enforce minimum size.
generator.DragMouseBy(-60, -60);
EXPECT_EQ(position, w1->bounds().origin());
- EXPECT_EQ(gfx::Size(50, 50), w1->bounds().size());
+ EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
}
TEST_F(ToplevelWindowEventFilterTest, Right) {
@@ -223,5 +218,87 @@ TEST_F(ToplevelWindowEventFilterTest, Client) {
EXPECT_EQ(bounds, w1->bounds());
}
+TEST_F(ToplevelWindowEventFilterTest, LeftPastMinimum) {
+ scoped_ptr<aura::Window> w1(CreateWindow(HTLEFT));
+ TestWindowDelegate* window_delegate =
+ static_cast<TestWindowDelegate*>(w1->delegate());
+ window_delegate->set_min_size(gfx::Size(40, 40));
+
+ // Simulate a large left-to-right drag. Window width should be clamped to
+ // minimum and position change should be limited as well.
+ DragFromCenterBy(w1.get(), 333, 0);
+ EXPECT_EQ(gfx::Point(60, 0), w1->bounds().origin());
+ EXPECT_EQ(gfx::Size(40, 100), w1->bounds().size());
+}
+
+TEST_F(ToplevelWindowEventFilterTest, RightPastMinimum) {
+ scoped_ptr<aura::Window> w1(CreateWindow(HTRIGHT));
+ TestWindowDelegate* window_delegate =
+ static_cast<TestWindowDelegate*>(w1->delegate());
+ window_delegate->set_min_size(gfx::Size(40, 40));
+ gfx::Point position = w1->bounds().origin();
+
+ // Simulate a large right-to-left drag. Window width should be clamped to
+ // minimum and position should not change.
+ DragFromCenterBy(w1.get(), -333, 0);
+ EXPECT_EQ(position, w1->bounds().origin());
+ EXPECT_EQ(gfx::Size(40, 100), w1->bounds().size());
+}
+
+TEST_F(ToplevelWindowEventFilterTest, TopLeftPastMinimum) {
+ scoped_ptr<aura::Window> w1(CreateWindow(HTTOPLEFT));
+ TestWindowDelegate* window_delegate =
+ static_cast<TestWindowDelegate*>(w1->delegate());
+ window_delegate->set_min_size(gfx::Size(40, 40));
+
+ // Simulate a large top-left to bottom-right drag. Window width should be
+ // clamped to minimum and position should be limited.
+ DragFromCenterBy(w1.get(), 333, 444);
+ EXPECT_EQ(gfx::Point(60, 60), w1->bounds().origin());
+ EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
+}
+
+TEST_F(ToplevelWindowEventFilterTest, TopRightPastMinimum) {
+ scoped_ptr<aura::Window> w1(CreateWindow(HTTOPRIGHT));
+ TestWindowDelegate* window_delegate =
+ static_cast<TestWindowDelegate*>(w1->delegate());
+ window_delegate->set_min_size(gfx::Size(40, 40));
+
+ // Simulate a large top-right to bottom-left drag. Window size should be
+ // clamped to minimum, x position should not change, and y position should
+ // be clamped.
+ DragFromCenterBy(w1.get(), -333, 444);
+ EXPECT_EQ(gfx::Point(0, 60), w1->bounds().origin());
+ EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
+}
+
+TEST_F(ToplevelWindowEventFilterTest, BottomLeftPastMinimum) {
+ scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMLEFT));
+ TestWindowDelegate* window_delegate =
+ static_cast<TestWindowDelegate*>(w1->delegate());
+ window_delegate->set_min_size(gfx::Size(40, 40));
+
+ // Simulate a large bottom-left to top-right drag. Window size should be
+ // clamped to minimum, x position should be clamped, and y position should
+ // not change.
+ DragFromCenterBy(w1.get(), 333, -444);
+ EXPECT_EQ(gfx::Point(60, 0), w1->bounds().origin());
+ EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
+}
+
+TEST_F(ToplevelWindowEventFilterTest, BottomRightPastMinimum) {
+ scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMRIGHT));
+ TestWindowDelegate* window_delegate =
+ static_cast<TestWindowDelegate*>(w1->delegate());
+ window_delegate->set_min_size(gfx::Size(40, 40));
+ gfx::Point position = w1->bounds().origin();
+
+ // Simulate a large bottom-right to top-left drag. Window size should be
+ // clamped to minimum and position should not change.
+ DragFromCenterBy(w1.get(), -333, -444);
+ EXPECT_EQ(position, w1->bounds().origin());
+ EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
+}
+
} // namespace test
} // namespace aura
« no previous file with comments | « ui/aura_shell/toplevel_window_event_filter.cc ('k') | ui/views/widget/native_widget_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698