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

Side by Side Diff: ash/wm/frame_painter_unittest.cc

Issue 10918077: Adding proper dragging behavior for L/R maximized windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: It looks like if git merged wrong here... Created 8 years, 3 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 | « ash/wm/frame_painter.cc ('k') | ash/wm/window_resizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/frame_painter.h" 5 #include "ash/wm/frame_painter.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/property_util.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "grit/ui_resources.h" 12 #include "grit/ui_resources.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
15 #include "ui/base/hit_test.h"
16 #include "ui/gfx/screen.h"
14 #include "ui/views/controls/button/image_button.h" 17 #include "ui/views/controls/button/image_button.h"
15 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
19 #include "ui/views/widget/widget_delegate.h"
20 #include "ui/views/window/non_client_view.h"
16 21
17 using views::Widget; 22 using views::Widget;
18 using views::ImageButton; 23 using views::ImageButton;
19 24
20 namespace { 25 namespace {
21 26
27 class ResizableWidgetDelegate : public views::WidgetDelegate {
28 public:
29 ResizableWidgetDelegate(views::Widget* widget) {
30 widget_ = widget;
31 }
32
33 virtual bool CanResize() const OVERRIDE { return true; }
34 // Implementations of the widget class.
35 virtual views::Widget* GetWidget() OVERRIDE { return widget_; }
36 virtual const views::Widget* GetWidget() const OVERRIDE { return widget_; }
37
38 private:
39 views::Widget* widget_;
40
41 DISALLOW_COPY_AND_ASSIGN(ResizableWidgetDelegate);
42 };
43
22 // Creates a test widget that owns its native widget. 44 // Creates a test widget that owns its native widget.
23 Widget* CreateTestWidget() { 45 Widget* CreateTestWidget() {
24 Widget* widget = new Widget; 46 Widget* widget = new Widget;
25 Widget::InitParams params; 47 Widget::InitParams params;
26 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 48 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
27 widget->Init(params); 49 widget->Init(params);
28 return widget; 50 return widget;
29 } 51 }
30 52
31 Widget* CreateAlwaysOnTopWidget() { 53 Widget* CreateAlwaysOnTopWidget() {
32 Widget* widget = new Widget; 54 Widget* widget = new Widget;
33 Widget::InitParams params; 55 Widget::InitParams params;
34 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 56 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
35 params.keep_on_top = true; 57 params.keep_on_top = true;
36 widget->Init(params); 58 widget->Init(params);
37 return widget; 59 return widget;
38 } 60 }
39 61
62 Widget* CreateResizableWidget() {
63 Widget* widget = new Widget;
64 Widget::InitParams params;
65 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
66 params.keep_on_top = true;
67 params.delegate = new ResizableWidgetDelegate(widget);
68 params.type = Widget::InitParams::TYPE_WINDOW;
69 widget->Init(params);
70 return widget;
71 }
72
40 } // namespace 73 } // namespace
41 74
42 namespace ash { 75 namespace ash {
43 76
44 typedef ash::test::AshTestBase FramePainterTest; 77 typedef ash::test::AshTestBase FramePainterTest;
45 78
46 TEST_F(FramePainterTest, Basics) { 79 TEST_F(FramePainterTest, Basics) {
47 // Other tests might have created a FramePainter, so we cannot assert that 80 // Other tests might have created a FramePainter, so we cannot assert that
48 // FramePainter::instances_ is NULL here. 81 // FramePainter::instances_ is NULL here.
49 82
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 NULL)); 187 NULL));
155 188
156 // Custom overlay image is drawn completely opaque. 189 // Custom overlay image is drawn completely opaque.
157 gfx::ImageSkia custom_overlay; 190 gfx::ImageSkia custom_overlay;
158 EXPECT_EQ(255, 191 EXPECT_EQ(255,
159 p1.GetHeaderOpacity(FramePainter::ACTIVE, 192 p1.GetHeaderOpacity(FramePainter::ACTIVE,
160 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE, 193 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE,
161 &custom_overlay)); 194 &custom_overlay));
162 } 195 }
163 196
197 // Test the hit test function with windows which are "partially maximized".
198 TEST_F(FramePainterTest, HitTestSpecialMaximizedModes) {
199 // Create a widget and a painter for it.
200 scoped_ptr<Widget> w1(CreateResizableWidget());
201 FramePainter p1;
202 ImageButton size1(NULL);
203 ImageButton close1(NULL);
204 p1.Init(w1.get(), NULL, &size1, &close1, FramePainter::SIZE_BUTTON_MAXIMIZES);
205 views::NonClientFrameView* frame = w1->non_client_view()->frame_view();
206 w1->Show();
207 gfx::Rect any_rect = gfx::Rect(0, 0, 100, 100);
208 gfx::Rect screen = gfx::Screen::GetDisplayMatching(any_rect).work_area();
209 w1->SetBounds(any_rect);
210 EXPECT_EQ(HTTOPLEFT, p1.NonClientHitTest(frame, gfx::Point(0, 15)));
211 w1->SetBounds(gfx::Rect(
212 screen.x(), screen.y(), screen.width() / 2, screen.height()));
213 // A hit without a set restore rect should produce a top left hit.
214 EXPECT_EQ(HTTOPLEFT, p1.NonClientHitTest(frame, gfx::Point(0, 15)));
215 ash::SetRestoreBoundsInScreen(w1->GetNativeWindow(), any_rect);
216 // A hit into the corner should produce nowhere - not left.
217 EXPECT_EQ(HTCAPTION, p1.NonClientHitTest(frame, gfx::Point(0, 15)));
218 // A hit into the middle upper area should generate right - not top&right.
219 EXPECT_EQ(HTRIGHT,
220 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, 15)));
221 // A hit into the middle should generate right.
222 EXPECT_EQ(HTRIGHT,
223 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2,
224 screen.height() / 2)));
225 // A hit into the middle lower area should generate right - not bottom&right.
226 EXPECT_EQ(HTRIGHT,
227 p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2,
228 screen.height() - 1)));
229 }
230
164 } // namespace ash 231 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/frame_painter.cc ('k') | ash/wm/window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698