15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 75c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "apps/ui/views/app_window_frame_view.h" 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/test/aura_test_base.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/window.h" 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window_event_dispatcher.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/controls/webview/webview.h" 135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "ui/wm/core/default_activation_client.h" 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/wm/core/easy_resize_window_targeter.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ShapedAppWindowTargeterTest : public aura::test::AuraTestBase { 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShapedAppWindowTargeterTest() 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : web_view_(NULL) { 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~ShapedAppWindowTargeterTest() {} 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Widget* widget() { return widget_.get(); } 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) extensions::NativeAppWindow* app_window() { return &app_window_; } 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ChromeNativeAppWindowViews* app_window_views() { return &app_window_; } 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) protected: 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void SetUp() OVERRIDE { 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::test::AuraTestBase::SetUp(); 325c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu new wm::DefaultActivationClient(root_window()); 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget_.reset(new views::Widget); 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) params.remove_standard_frame = true; 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) params.bounds = gfx::Rect(30, 30, 100, 100); 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) params.context = root_window(); 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget_->Init(params); 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) app_window_.set_web_view_for_testing(&web_view_); 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) app_window_.set_window_for_testing(widget_.get()); 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget_->Show(); 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void TearDown() OVERRIDE { 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget_.reset(); 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::test::AuraTestBase::TearDown(); 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::WebView web_view_; 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<views::Widget> widget_; 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ChromeNativeAppWindowViews app_window_; 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(ShapedAppWindowTargeterTest); 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) { 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* window = widget()->GetNativeWindow(); 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Without any custom shapes, the event should be targeted correctly to the 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // window. 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point(40, 40), gfx::Point(40, 40), 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(window, move.target()); 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<SkRegion> region(new SkRegion); 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) region->op(SkIRect::MakeXYWH(40, 0, 20, 100), SkRegion::kUnion_Op); 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) region->op(SkIRect::MakeXYWH(0, 40, 100, 20), SkRegion::kUnion_Op); 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) app_window()->UpdateShape(region.Pass()); 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // With the custom shape, the events that don't fall within the custom shape 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // will go through to the root window. 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point(40, 40), gfx::Point(40, 40), 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 84a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 85a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(root_window(), move.target()); 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // But events within the shape will still reach the window. 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::MouseEvent move2(ui::ET_MOUSE_MOVED, 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point(80, 80), gfx::Point(80, 80), 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) details = event_processor()->OnEventFromSource(&move2); 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(window, move2.target()); 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(ShapedAppWindowTargeterTest, HitTestOnlyForShapedWindow) { 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Install a window-targeter on the root window that allows a window to 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // receive events outside of its bounds. Verify that this window-targeter is 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // active unless the window has a custom shape. 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Insets inset(-30, -30, -30, -30); 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) root_window()->SetEventTargeter(scoped_ptr<ui::EventTargeter>( 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new wm::EasyResizeWindowTargeter(root_window(), inset, inset))); 1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* window = widget()->GetNativeWindow(); 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Without any custom shapes, an event within the window bounds should be 1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // targeted correctly to the window. 1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point(40, 40), gfx::Point(40, 40), 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(window, move.target()); 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Without any custom shapes, an event that falls just outside the window 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // bounds should also be targeted correctly to the window, because of the 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // targeter installed on the root-window. 1235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point(10, 10), gfx::Point(10, 10), 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 1285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 1295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(window, move.target()); 1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<SkRegion> region(new SkRegion); 1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) region->op(SkIRect::MakeXYWH(40, 0, 20, 100), SkRegion::kUnion_Op); 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) region->op(SkIRect::MakeXYWH(0, 40, 100, 20), SkRegion::kUnion_Op); 1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) app_window()->UpdateShape(region.Pass()); 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // With the custom shape, the events that don't fall within the custom shape 1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // will go through to the root window. 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point(10, 10), gfx::Point(10, 10), 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(root_window(), move.target()); 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Remove the custom shape. This should restore the behaviour of targeting the 1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // app window for events just outside its bounds. 1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) app_window()->UpdateShape(scoped_ptr<SkRegion>()); 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point(10, 10), gfx::Point(10, 10), 1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 155a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 156a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(window, move.target()); 1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 161a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 162a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Tests targeting of events on a window with an EasyResizeWindowTargeter 163a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// installed on its container. 164a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TEST_F(ShapedAppWindowTargeterTest, ResizeInsetsWithinBounds) { 165a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* window = widget()->GetNativeWindow(); 166a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) { 167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // An event in the center of the window should always have 168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // |window| as its target. 169a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Point(80, 80), gfx::Point(80, 80), 171a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 173a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 174a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 175a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(window, move.target()); 176a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 177a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) { 178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Without an EasyResizeTargeter on the container, an event 179a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // inside the window and within 5px of an edge should have 180a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // |window| as its target. 181a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 182a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Point(32, 37), gfx::Point(32, 37), 183a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(window, move.target()); 188a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1905c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#if !defined(OS_CHROMEOS) 1915c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // The non standard app frame has a easy resize targetter installed. 1925c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu scoped_ptr<apps::AppWindowFrameView> frame( 1935c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu app_window_views()->CreateNonStandardAppFrame()); 194a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) { 195a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Ensure that the window has an event targeter (there should be an 196a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // EasyResizeWindowTargeter installed). 197a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_TRUE(static_cast<ui::EventTarget*>(window)->GetEventTargeter()); 198a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch } 199a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch { 200a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // An event in the center of the window should always have 201a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // |window| as its target. 202a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // TODO(mgiuca): This isn't really testing anything (note that it has the 203a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // same expectation as the border case below). In the real environment, the 204a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // target will actually be the RenderWidgetHostViewAura's window that is the 205a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // child of the child of |window|, whereas in the border case it *will* be 206a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // |window|. However, since this test environment does not have a 207a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // RenderWidgetHostViewAura, we cannot differentiate the two cases. Fix 208a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // the test environment so that the test can assert that non-border events 209a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // bubble down to a child of |window|. 210a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 211a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Point(80, 80), gfx::Point(80, 80), 212a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 213a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 214a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) EXPECT_EQ(window, move.target()); 217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 218a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) { 219a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // With an EasyResizeTargeter on the container, an event 220a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // inside the window and within 5px of an edge should have 221a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // |window| as its target. 222a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::MouseEvent move(ui::ET_MOUSE_MOVED, 223a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Point(32, 37), gfx::Point(32, 37), 224a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EF_NONE, ui::EF_NONE); 225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui::EventDispatchDetails details = 226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event_processor()->OnEventFromSource(&move); 227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(details.dispatcher_destroyed); 228a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch EXPECT_EQ(window, move.target()); 229a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 2305c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#endif // defined (OS_CHROMEOS) 231a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 232