| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/cursor_client.h" | 7 #include "ui/aura/client/cursor_client.h" |
| 8 #include "ui/aura/root_window.h" | 8 #include "ui/aura/root_window.h" |
| 9 #include "ui/aura/test/test_window_delegate.h" |
| 9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 10 #include "ui/views/test/views_test_base.h" | 11 #include "ui/views/test/views_test_base.h" |
| 11 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 12 | 13 |
| 13 namespace views { | 14 namespace views { |
| 14 | 15 |
| 15 typedef ViewsTestBase DesktopNativeWidgetAuraTest; | 16 typedef ViewsTestBase DesktopNativeWidgetAuraTest; |
| 16 | 17 |
| 17 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't | 18 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't |
| 18 // crash. | 19 // crash. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 EXPECT_FALSE(cursor_client_a->IsCursorVisible()); | 153 EXPECT_FALSE(cursor_client_a->IsCursorVisible()); |
| 153 EXPECT_FALSE(cursor_client_b->IsCursorVisible()); | 154 EXPECT_FALSE(cursor_client_b->IsCursorVisible()); |
| 154 | 155 |
| 155 // Verify the cursor becomes visible on unlock (since a request | 156 // Verify the cursor becomes visible on unlock (since a request |
| 156 // to make it visible was queued up while the cursor was locked). | 157 // to make it visible was queued up while the cursor was locked). |
| 157 cursor_client_b->UnlockCursor(); | 158 cursor_client_b->UnlockCursor(); |
| 158 EXPECT_TRUE(cursor_client_a->IsCursorVisible()); | 159 EXPECT_TRUE(cursor_client_a->IsCursorVisible()); |
| 159 EXPECT_TRUE(cursor_client_b->IsCursorVisible()); | 160 EXPECT_TRUE(cursor_client_b->IsCursorVisible()); |
| 160 } | 161 } |
| 161 | 162 |
| 163 // Verifies FocusController doesn't attempt to access |content_window_| during |
| 164 // destruction. Previously the FocusController was destroyed after the window. |
| 165 // This could be problematic as FocusController references |content_window_| and |
| 166 // could attempt to use it after |content_window_| was destroyed. This test |
| 167 // verifies this doesn't happen. Note that this test only failed under ASAN. |
| 168 TEST_F(DesktopNativeWidgetAuraTest, DontAccessContentWindowDuringDestruction) { |
| 169 aura::test::TestWindowDelegate delegate; |
| 170 { |
| 171 Widget widget; |
| 172 Widget::InitParams init_params = |
| 173 CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 174 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 175 DesktopNativeWidgetAura* desktop_native_widget_aura = |
| 176 new DesktopNativeWidgetAura(&widget); |
| 177 init_params.native_widget = desktop_native_widget_aura; |
| 178 widget.Init(init_params); |
| 179 |
| 180 // Owned by |widget|. |
| 181 aura::Window* window = new aura::Window(&delegate); |
| 182 window->Show(); |
| 183 widget.GetNativeWindow()->parent()->AddChild(window); |
| 184 |
| 185 widget.Show(); |
| 186 } |
| 187 } |
| 188 |
| 162 } // namespace views | 189 } // namespace views |
| OLD | NEW |