Index: ash/wm/frame_painter_unittest.cc |
diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc |
index c918f23a618d4c14edc5e42e27159276d895b7c5..266844eaddb2a0b91266df5b0b8dd422fce460b3 100644 |
--- a/ash/wm/frame_painter_unittest.cc |
+++ b/ash/wm/frame_painter_unittest.cc |
@@ -7,18 +7,37 @@ |
#include "ash/shell.h" |
#include "ash/shell_window_ids.h" |
#include "ash/test/ash_test_base.h" |
+#include "ash/wm/property_util.h" |
#include "base/memory/scoped_ptr.h" |
#include "grit/ui_resources.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/aura/root_window.h" |
+#include "ui/base/hit_test.h" |
+#include "ui/gfx/screen.h" |
#include "ui/views/controls/button/image_button.h" |
#include "ui/views/widget/widget.h" |
+#include "ui/views/widget/widget_delegate.h" |
+#include "ui/views/window/non_client_view.h" |
using views::Widget; |
using views::ImageButton; |
namespace { |
+class ResizableWidgetDelegate : public views::WidgetDelegate { |
+ public: |
+ ResizableWidgetDelegate(views::Widget* widget) { |
+ widget_ = widget; |
+ } |
+ |
+ virtual bool CanResize() const OVERRIDE { return true; } |
+ // Implementations of the widget class. |
+ virtual views::Widget* GetWidget() {return widget_; } |
sky
2012/09/06 19:45:11
OVERRIDE on these two lines, and space after {
Mr4D (OOO till 08-26)
2012/09/06 23:16:13
Done.
|
+ virtual const views::Widget* GetWidget() const { return widget_; } |
+ private: |
sky
2012/09/06 19:45:11
newline bewteen 36/67.
Mr4D (OOO till 08-26)
2012/09/06 23:16:13
Done.
|
+ views::Widget* widget_; |
+}; |
sky
2012/09/06 19:45:11
DISALLOW_...
Mr4D (OOO till 08-26)
2012/09/06 23:16:13
Done.
|
+ |
// Creates a test widget that owns its native widget. |
Widget* CreateTestWidget() { |
Widget* widget = new Widget; |
@@ -37,6 +56,17 @@ Widget* CreateAlwaysOnTopWidget() { |
return widget; |
} |
+Widget* CreateResizableWidget() { |
+ Widget* widget = new Widget; |
+ Widget::InitParams params; |
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
+ params.keep_on_top = true; |
+ params.delegate = new ResizableWidgetDelegate(widget); |
+ params.type = Widget::InitParams::TYPE_WINDOW; |
+ widget->Init(params); |
+ return widget; |
+} |
+ |
} // namespace |
namespace ash { |
@@ -161,4 +191,44 @@ TEST_F(FramePainterTest, GetHeaderOpacity) { |
&custom_overlay)); |
} |
+// Test the hit test function with windows which are "partially maximized". |
+TEST_F(FramePainterTest, HitTestSpecialMaximizedModes) { |
+ // Create a widget and a painter for it. |
+ scoped_ptr<Widget> w1(CreateResizableWidget()); |
+ views::NonClientFrameView* frame = w1->CreateNonClientFrameView(); |
+ FramePainter p1; |
+ ImageButton size1(NULL); |
+ ImageButton close1(NULL); |
+ p1.Init(w1.get(), NULL, &size1, &close1, FramePainter::SIZE_BUTTON_MAXIMIZES); |
+ w1->Show(); |
+ gfx::Rect any_rect = gfx::Rect(0, 0, 100, 100); |
+ w1->SetBounds(any_rect); |
+ frame->SetBounds(0, 0, 100, 100); |
sky
2012/09/06 19:45:11
Why do you need this? w1->SetBounds should take ca
Mr4D (OOO till 08-26)
2012/09/06 23:16:13
You need both. I was puzzled by this myself when w
sky
2012/09/07 02:43:30
Please investigate this more deeply. Setting the f
Mr4D (OOO till 08-26)
2012/09/08 01:17:41
I have dumped already several hours on this and wi
|
+ EXPECT_EQ(HTTOPLEFT, |
+ p1.NonClientHitTest(frame, gfx::Point(0, 15))); |
+ gfx::Rect screen = gfx::Screen::GetDisplayMatching(any_rect).work_area(); |
+ w1->SetBounds(gfx::Rect( |
+ screen.x(), screen.y(), screen.width() / 2, screen.height())); |
+ frame->SetBounds( |
+ screen.x(), screen.y(), screen.width() / 2, screen.height()); |
+ // A hit without a set restore rect should produce a top left hit. |
+ EXPECT_EQ(HTTOPLEFT, |
+ p1.NonClientHitTest(frame, gfx::Point(0, 15))); |
+ ash::SetRestoreBoundsInScreen(w1->GetNativeWindow(), any_rect); |
+ // A hit into the corner should produce nowhere - not left. |
+ EXPECT_EQ(HTCAPTION, |
+ p1.NonClientHitTest(frame, gfx::Point(0, 15))); |
+ // A hit into the middle upper area should generate right - not top&right. |
+ EXPECT_EQ(HTRIGHT, |
+ p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, 15))); |
+ // A hit into the middle should generate right. |
+ EXPECT_EQ(HTRIGHT, |
+ p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, |
+ screen.height() / 2))); |
+ // A hit into the middle lower area should generate right - not bottom&right. |
+ EXPECT_EQ(HTRIGHT, |
+ p1.NonClientHitTest(frame, gfx::Point(screen.width() / 2, |
+ screen.height() - 1))); |
+} |
+ |
} // namespace ash |