| OLD | NEW |
| 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 "ui/views/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 class NativeWidgetAuraTest : public ViewsTestBase { | 35 class NativeWidgetAuraTest : public ViewsTestBase { |
| 36 public: | 36 public: |
| 37 NativeWidgetAuraTest() {} | 37 NativeWidgetAuraTest() {} |
| 38 virtual ~NativeWidgetAuraTest() {} | 38 virtual ~NativeWidgetAuraTest() {} |
| 39 | 39 |
| 40 // testing::Test overrides: | 40 // testing::Test overrides: |
| 41 virtual void SetUp() OVERRIDE { | 41 virtual void SetUp() OVERRIDE { |
| 42 ViewsTestBase::SetUp(); | 42 ViewsTestBase::SetUp(); |
| 43 dispatcher()->host()->SetBounds(gfx::Rect(640, 480)); | 43 host()->SetBounds(gfx::Rect(640, 480)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 aura::Window* root_window() { return GetContext(); } | 47 aura::Window* root_window() { return GetContext(); } |
| 48 aura::WindowEventDispatcher* dispatcher() { | |
| 49 return root_window()->GetHost()->dispatcher(); | |
| 50 } | |
| 51 | 48 |
| 52 private: | 49 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); | 50 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); |
| 54 }; | 51 }; |
| 55 | 52 |
| 56 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { | 53 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { |
| 57 // Make a parent window larger than the host represented by | 54 // Make a parent window larger than the host represented by |
| 58 // WindowEventDispatcher. | 55 // WindowEventDispatcher. |
| 59 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 56 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 60 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 57 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 243 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 247 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 244 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 248 params.context = root_window(); | 245 params.context = root_window(); |
| 249 params.bounds = gfx::Rect(0, 0, 100, 200); | 246 params.bounds = gfx::Rect(0, 0, 100, 200); |
| 250 widget->Init(params); | 247 widget->Init(params); |
| 251 widget->SetContentsView(view); | 248 widget->SetContentsView(view); |
| 252 widget->Show(); | 249 widget->Show(); |
| 253 | 250 |
| 254 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, | 251 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, |
| 255 base::TimeDelta()); | 252 base::TimeDelta()); |
| 256 ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&press); | 253 ui::EventDispatchDetails details = |
| 254 event_processor()->OnEventFromSource(&press); |
| 257 ASSERT_FALSE(details.dispatcher_destroyed); | 255 ASSERT_FALSE(details.dispatcher_destroyed); |
| 258 // Both views should get the press. | 256 // Both views should get the press. |
| 259 EXPECT_TRUE(view->got_gesture_event()); | 257 EXPECT_TRUE(view->got_gesture_event()); |
| 260 EXPECT_TRUE(child->got_gesture_event()); | 258 EXPECT_TRUE(child->got_gesture_event()); |
| 261 view->clear_got_gesture_event(); | 259 view->clear_got_gesture_event(); |
| 262 child->clear_got_gesture_event(); | 260 child->clear_got_gesture_event(); |
| 263 // Touch events should not automatically grab capture. | 261 // Touch events should not automatically grab capture. |
| 264 EXPECT_FALSE(widget->HasCapture()); | 262 EXPECT_FALSE(widget->HasCapture()); |
| 265 | 263 |
| 266 // Release touch. Only |view| should get the release since that it consumed | 264 // Release touch. Only |view| should get the release since that it consumed |
| 267 // the press. | 265 // the press. |
| 268 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1, | 266 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1, |
| 269 base::TimeDelta()); | 267 base::TimeDelta()); |
| 270 details = dispatcher()->OnEventFromSource(&release); | 268 details = event_processor()->OnEventFromSource(&release); |
| 271 ASSERT_FALSE(details.dispatcher_destroyed); | 269 ASSERT_FALSE(details.dispatcher_destroyed); |
| 272 EXPECT_TRUE(view->got_gesture_event()); | 270 EXPECT_TRUE(view->got_gesture_event()); |
| 273 EXPECT_FALSE(child->got_gesture_event()); | 271 EXPECT_FALSE(child->got_gesture_event()); |
| 274 view->clear_got_gesture_event(); | 272 view->clear_got_gesture_event(); |
| 275 | 273 |
| 276 // Work around for bug in NativeWidgetAura. | 274 // Work around for bug in NativeWidgetAura. |
| 277 // TODO: fix bug and remove this. | 275 // TODO: fix bug and remove this. |
| 278 widget->Close(); | 276 widget->Close(); |
| 279 } | 277 } |
| 280 | 278 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 delegate->ClearGotMove(); | 404 delegate->ClearGotMove(); |
| 407 // Simulate a maximize with animation. | 405 // Simulate a maximize with animation. |
| 408 delete widget->GetNativeView()->RecreateLayer(); | 406 delete widget->GetNativeView()->RecreateLayer(); |
| 409 widget->SetBounds(gfx::Rect(0, 0, 500, 500)); | 407 widget->SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 410 EXPECT_TRUE(delegate->got_move()); | 408 EXPECT_TRUE(delegate->got_move()); |
| 411 widget->CloseNow(); | 409 widget->CloseNow(); |
| 412 } | 410 } |
| 413 | 411 |
| 414 } // namespace | 412 } // namespace |
| 415 } // namespace views | 413 } // namespace views |
| OLD | NEW |