1424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// found in the LICENSE file. 4424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 6f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/bind.h" 86d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "ui/aura/client/aura_constants.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/client/cursor_client.h" 106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "ui/aura/client/window_tree_client.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/test/test_window_delegate.h" 12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ui/aura/window.h" 1323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ui/aura/window_tree_host.h" 145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ui/events/test/event_generator.h" 15424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "ui/views/test/views_test_base.h" 166d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "ui/views/test/widget_test.h" 17424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "ui/views/widget/widget.h" 18effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "ui/wm/public/dispatcher_client.h" 19424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 20424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace views { 216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)namespace test { 22424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 23424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)typedef ViewsTestBase DesktopNativeWidgetAuraTest; 24424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 25424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Verifies creating a Widget with a parent that is not in a RootWindow doesn't 26424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// crash. 27424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) { 28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) scoped_ptr<aura::Window> window(new aura::Window(NULL)); 29424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Widget widget; 30424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 31424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) params.bounds = gfx::Rect(0, 0, 200, 200); 32424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) params.parent = window.get(); 33424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 34424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) params.native_widget = new DesktopNativeWidgetAura(&widget); 35424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) widget.Init(params); 36424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} 37424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 3846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// Verifies that the Aura windows making up a widget instance have the correct 394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// bounds after the widget is resized. 404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)TEST_F(DesktopNativeWidgetAuraTest, DesktopAuraWindowSizeTest) { 414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) Widget widget; 4246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 4346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // On Linux we test this with popup windows because the WM may ignore the size 4446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // suggestion for normal windows. 4546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#if defined(OS_LINUX) 4646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) Widget::InitParams init_params = 4746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) CreateParams(Widget::InitParams::TYPE_POPUP); 4846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#else 494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) Widget::InitParams init_params = 504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 5146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#endif 5246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) init_params.native_widget = new DesktopNativeWidgetAura(&widget); 554e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.Init(init_params); 564e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect bounds(0, 0, 100, 100); 584e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.SetBounds(bounds); 594e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.Show(); 604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(bounds.ToString(), 624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.GetNativeView()->GetRootWindow()->bounds().ToString()); 634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(bounds.ToString(), widget.GetNativeView()->bounds().ToString()); 644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(bounds.ToString(), 654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.GetNativeView()->parent()->bounds().ToString()); 664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gfx::Rect new_bounds(0, 0, 200, 200); 684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.SetBounds(new_bounds); 694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(new_bounds.ToString(), 704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.GetNativeView()->GetRootWindow()->bounds().ToString()); 714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(new_bounds.ToString(), widget.GetNativeView()->bounds().ToString()); 724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) EXPECT_EQ(new_bounds.ToString(), 734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) widget.GetNativeView()->parent()->bounds().ToString()); 744e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 754e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Verifies GetNativeView() is initially hidden. If the native view is initially 771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// shown then animations can not be disabled. 781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(DesktopNativeWidgetAuraTest, NativeViewInitiallyHidden) { 791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) Widget widget; 801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) Widget::InitParams init_params = 811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) CreateParams(Widget::InitParams::TYPE_WINDOW); 821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) init_params.native_widget = new DesktopNativeWidgetAura(&widget); 841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) widget.Init(init_params); 851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) EXPECT_FALSE(widget.GetNativeView()->IsVisible()); 861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Verify that the cursor state is shared between two native widgets. 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(DesktopNativeWidgetAuraTest, GlobalCursorState) { 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Create two native widgets, each owning different root windows. 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Widget widget_a; 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Widget::InitParams init_params_a = 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateParams(Widget::InitParams::TYPE_WINDOW); 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) init_params_a.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DesktopNativeWidgetAura* desktop_native_widget_aura_a = 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new DesktopNativeWidgetAura(&widget_a); 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) init_params_a.native_widget = desktop_native_widget_aura_a; 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget_a.Init(init_params_a); 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Widget widget_b; 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Widget::InitParams init_params_b = 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateParams(Widget::InitParams::TYPE_WINDOW); 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) init_params_b.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DesktopNativeWidgetAura* desktop_native_widget_aura_b = 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new DesktopNativeWidgetAura(&widget_b); 1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) init_params_b.native_widget = desktop_native_widget_aura_b; 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget_b.Init(init_params_b); 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::client::CursorClient* cursor_client_a = aura::client::GetCursorClient( 110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) desktop_native_widget_aura_a->host()->window()); 1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::client::CursorClient* cursor_client_b = aura::client::GetCursorClient( 112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) desktop_native_widget_aura_b->host()->window()); 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Verify the cursor can be locked using one client and unlocked using 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // another. 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_a->IsCursorLocked()); 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_b->IsCursorLocked()); 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_a->LockCursor(); 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_a->IsCursorLocked()); 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_b->IsCursorLocked()); 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_b->UnlockCursor(); 1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_a->IsCursorLocked()); 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_b->IsCursorLocked()); 1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Verify that mouse events can be disabled using one client and then 1285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // re-enabled using another. Note that disabling mouse events should also 1295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // have the side effect of making the cursor invisible. 1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_a->IsCursorVisible()); 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_b->IsCursorVisible()); 1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_a->IsMouseEventsEnabled()); 1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_b->IsMouseEventsEnabled()); 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_b->DisableMouseEvents(); 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_a->IsCursorVisible()); 1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_b->IsCursorVisible()); 1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_a->IsMouseEventsEnabled()); 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_b->IsMouseEventsEnabled()); 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_a->EnableMouseEvents(); 1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_a->IsCursorVisible()); 1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_b->IsCursorVisible()); 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_a->IsMouseEventsEnabled()); 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_b->IsMouseEventsEnabled()); 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Verify that setting the cursor using one cursor client 1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // will set it for all root windows. 1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(ui::kCursorNone, cursor_client_a->GetCursor().native_type()); 1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(ui::kCursorNone, cursor_client_b->GetCursor().native_type()); 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_b->SetCursor(ui::kCursorPointer); 1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(ui::kCursorPointer, cursor_client_a->GetCursor().native_type()); 1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(ui::kCursorPointer, cursor_client_b->GetCursor().native_type()); 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Verify that hiding the cursor using one cursor client will 1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // hide it for all root windows. Note that hiding the cursor 1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // should not disable mouse events. 1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_a->HideCursor(); 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_a->IsCursorVisible()); 1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_b->IsCursorVisible()); 1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_a->IsMouseEventsEnabled()); 1635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_b->IsMouseEventsEnabled()); 1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Verify that the visibility state cannot be changed using one 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // cursor client when the cursor was locked using another. 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_b->LockCursor(); 1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_a->ShowCursor(); 1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_a->IsCursorVisible()); 1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(cursor_client_b->IsCursorVisible()); 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Verify the cursor becomes visible on unlock (since a request 1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // to make it visible was queued up while the cursor was locked). 1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) cursor_client_b->UnlockCursor(); 1755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_a->IsCursorVisible()); 1765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(cursor_client_b->IsCursorVisible()); 1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Verifies FocusController doesn't attempt to access |content_window_| during 1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// destruction. Previously the FocusController was destroyed after the window. 1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// This could be problematic as FocusController references |content_window_| and 1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// could attempt to use it after |content_window_| was destroyed. This test 1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// verifies this doesn't happen. Note that this test only failed under ASAN. 1845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(DesktopNativeWidgetAuraTest, DontAccessContentWindowDuringDestruction) { 1855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::test::TestWindowDelegate delegate; 1865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 1875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Widget widget; 1885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Widget::InitParams init_params = 1895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateParams(Widget::InitParams::TYPE_WINDOW); 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DesktopNativeWidgetAura* desktop_native_widget_aura = 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new DesktopNativeWidgetAura(&widget); 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) init_params.native_widget = desktop_native_widget_aura; 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget.Init(init_params); 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Owned by |widget|. 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* window = new aura::Window(&delegate); 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) window->Show(); 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget.GetNativeWindow()->parent()->AddChild(window); 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget.Show(); 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 205a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void QuitNestedLoopAndCloseWidget(scoped_ptr<Widget> widget, 206cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::Closure* quit_runloop) { 207cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) quit_runloop->Run(); 208a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 209a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 210a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Verifies that a widget can be destroyed when running a nested message-loop. 211a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)TEST_F(DesktopNativeWidgetAuraTest, WidgetCanBeDestroyedFromNestedLoop) { 212a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<Widget> widget(new Widget); 213a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 214a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) params.bounds = gfx::Rect(0, 0, 200, 200); 215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) params.native_widget = new DesktopNativeWidgetAura(widget.get()); 217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) widget->Init(params); 218a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) widget->Show(); 219a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 220a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* window = widget->GetNativeView(); 221a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* root = window->GetRootWindow(); 222a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::client::DispatcherClient* client = 223a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::client::GetDispatcherClient(root); 224a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Post a task that terminates the nested loop and destroyes the widget. This 226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // task will be executed from the nested loop initiated with the call to 227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // |RunWithDispatcher()| below. 228cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) aura::client::DispatcherRunLoop run_loop(client, NULL); 229cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::Closure quit_runloop = run_loop.QuitClosure(); 230a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) message_loop()->PostTask(FROM_HERE, 231cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::Bind(&QuitNestedLoopAndCloseWidget, 232cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::Passed(&widget), 233cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::Unretained(&quit_runloop))); 234cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) run_loop.Run(); 235a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 236a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 2376d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// This class provides functionality to create fullscreen and top level popup 2386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// windows. It additionally tests whether the destruction of these windows 2396d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// occurs correctly in desktop AURA without crashing. 2406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// It provides facilities to test the following cases:- 2416d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// 1. Child window destroyed which should lead to the destruction of the 2426d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// parent. 2436d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// 2. Parent window destroyed which should lead to the child being destroyed. 2446d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class DesktopAuraTopLevelWindowTest 2456d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) : public views::TestViewsDelegate, 2466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) public aura::WindowObserver { 2476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) public: 2486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DesktopAuraTopLevelWindowTest() 2496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) : top_level_widget_(NULL), 2506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_(NULL), 2516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owner_destroyed_(false), 2526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_destroyed_(false) {} 2536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual ~DesktopAuraTopLevelWindowTest() { 2556d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) EXPECT_TRUE(owner_destroyed_); 2566d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) EXPECT_TRUE(owned_window_destroyed_); 2576d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) top_level_widget_ = NULL; 2586d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_ = NULL; 2596d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 2606d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2616d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // views::TestViewsDelegate overrides. 2626d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual void OnBeforeWidgetInit( 2636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) Widget::InitParams* params, 2646d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) internal::NativeWidgetDelegate* delegate) OVERRIDE { 2656d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) if (!params->native_widget) 2666d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) params->native_widget = new views::DesktopNativeWidgetAura(delegate); 2676d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 2686d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2696d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) void CreateTopLevelWindow(const gfx::Rect& bounds, bool fullscreen) { 2706d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) Widget::InitParams init_params; 2716d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) init_params.type = Widget::InitParams::TYPE_WINDOW; 2726d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) init_params.bounds = bounds; 2736d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 2746d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) init_params.layer_type = aura::WINDOW_LAYER_NOT_DRAWN; 2756d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) init_params.accept_events = fullscreen; 2766d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2776d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) widget_.Init(init_params); 2786d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2796d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_ = new aura::Window(&child_window_delegate_); 2806d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); 2816d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->SetName("TestTopLevelWindow"); 2826d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) if (fullscreen) { 2836d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->SetProperty(aura::client::kShowStateKey, 2846d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ui::SHOW_STATE_FULLSCREEN); 2856d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } else { 2866d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->SetType(ui::wm::WINDOW_TYPE_MENU); 2876d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 2886d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->Init(aura::WINDOW_LAYER_TEXTURED); 2896d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) aura::client::ParentWindowWithContext( 2906d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_, 2916d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) widget_.GetNativeView()->GetRootWindow(), 2926d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) gfx::Rect(0, 0, 1900, 1600)); 2936d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->Show(); 2946d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->AddObserver(this); 2956d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2966d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_TRUE(owned_window_->parent() != NULL); 2976d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_->parent()->AddObserver(this); 2986d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2996d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) top_level_widget_ = 3006d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) views::Widget::GetWidgetForNativeView(owned_window_->parent()); 3016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_TRUE(top_level_widget_ != NULL); 3026d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3036d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3046d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) void DestroyOwnedWindow() { 3056d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_TRUE(owned_window_ != NULL); 3066d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) delete owned_window_; 3076d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3086d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3096d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) void DestroyOwnerWindow() { 3106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_TRUE(top_level_widget_ != NULL); 3116d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) top_level_widget_->CloseNow(); 3126d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { 3156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) window->RemoveObserver(this); 3166d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) if (window == owned_window_) { 3176d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owned_window_destroyed_ = true; 3186d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } else if (window == top_level_widget_->GetNativeView()) { 3196d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) owner_destroyed_ = true; 3206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } else { 3216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ADD_FAILURE() << "Unexpected window destroyed callback: " << window; 3226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3236d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) aura::Window* owned_window() { 3266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) return owned_window_; 3276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3286d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) views::Widget* top_level_widget() { 3306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) return top_level_widget_; 3316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) private: 3346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) views::Widget widget_; 3356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) views::Widget* top_level_widget_; 3366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) aura::Window* owned_window_; 3376d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) bool owner_destroyed_; 3386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) bool owned_window_destroyed_; 3396d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) aura::test::TestWindowDelegate child_window_delegate_; 3406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3416d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); 3426d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}; 3436d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3446d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)typedef WidgetTest DesktopAuraWidgetTest; 3456d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)TEST_F(DesktopAuraWidgetTest, FullscreenWindowDestroyedBeforeOwnerTest) { 3476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ViewsDelegate::views_delegate = NULL; 3486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DesktopAuraTopLevelWindowTest fullscreen_window; 3496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( 3506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) gfx::Rect(0, 0, 200, 200), true)); 3516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnedWindow()); 3546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3556d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 3566d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3576d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)TEST_F(DesktopAuraWidgetTest, FullscreenWindowOwnerDestroyed) { 3586d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ViewsDelegate::views_delegate = NULL; 3596d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3606d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DesktopAuraTopLevelWindowTest fullscreen_window; 3616d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( 3626d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) gfx::Rect(0, 0, 200, 200), true)); 3636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3646d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3656d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnerWindow()); 3666d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3676d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 3686d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3696d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupTest) { 3706d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ViewsDelegate::views_delegate = NULL; 3716d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DesktopAuraTopLevelWindowTest popup_window; 3726d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( 3736d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) gfx::Rect(0, 0, 200, 200), false)); 3746d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3756d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3766d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); 3776d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3786d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 3796d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3806d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// This test validates that when a top level owned popup Aura window is 3816d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// resized, the widget is resized as well. 3826d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupResizeTest) { 3836d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ViewsDelegate::views_delegate = NULL; 3846d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DesktopAuraTopLevelWindowTest popup_window; 3856d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( 3866d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) gfx::Rect(0, 0, 200, 200), false)); 3876d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3886d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) gfx::Rect new_size(0, 0, 400, 400); 3896d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) popup_window.owned_window()->SetBounds(new_size); 3906d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3916d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) EXPECT_EQ(popup_window.top_level_widget()->GetNativeView()->bounds().size(), 3926d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) new_size.size()); 3936d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3946d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); 3956d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) RunPendingMessages(); 3966d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 3976d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3986d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} // namespace test 399424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} // namespace views 400