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 <memory> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/aura/client/aura_constants.h" | 13 #include "ui/aura/client/aura_constants.h" |
13 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
14 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
15 #include "ui/aura/test/aura_test_base.h" | 16 #include "ui/aura/test/aura_test_base.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
17 #include "ui/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
18 #include "ui/events/event.h" | 19 #include "ui/events/event.h" |
19 #include "ui/events/event_utils.h" | 20 #include "ui/events/event_utils.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // testing::Test overrides: | 72 // testing::Test overrides: |
72 void SetUp() override { | 73 void SetUp() override { |
73 AuraTestBase::SetUp(); | 74 AuraTestBase::SetUp(); |
74 test_focus_rules_ = new TestFocusRules; | 75 test_focus_rules_ = new TestFocusRules; |
75 focus_controller_.reset(new wm::FocusController(test_focus_rules_)); | 76 focus_controller_.reset(new wm::FocusController(test_focus_rules_)); |
76 aura::client::SetActivationClient(root_window(), focus_controller_.get()); | 77 aura::client::SetActivationClient(root_window(), focus_controller_.get()); |
77 host()->SetBounds(gfx::Rect(640, 480)); | 78 host()->SetBounds(gfx::Rect(640, 480)); |
78 } | 79 } |
79 | 80 |
80 private: | 81 private: |
81 scoped_ptr<wm::FocusController> focus_controller_; | 82 std::unique_ptr<wm::FocusController> focus_controller_; |
82 TestFocusRules* test_focus_rules_; | 83 TestFocusRules* test_focus_rules_; |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); | 85 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); |
85 }; | 86 }; |
86 | 87 |
87 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { | 88 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { |
88 // Make a parent window larger than the host represented by | 89 // Make a parent window larger than the host represented by |
89 // WindowEventDispatcher. | 90 // WindowEventDispatcher. |
90 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 91 std::unique_ptr<aura::Window> parent(new aura::Window(NULL)); |
91 parent->Init(ui::LAYER_NOT_DRAWN); | 92 parent->Init(ui::LAYER_NOT_DRAWN); |
92 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); | 93 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); |
93 scoped_ptr<Widget> widget(new Widget()); | 94 std::unique_ptr<Widget> widget(new Widget()); |
94 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 95 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
95 | 96 |
96 window->CenterWindow(gfx::Size(100, 100)); | 97 window->CenterWindow(gfx::Size(100, 100)); |
97 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, | 98 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, |
98 (480 - 100) / 2, | 99 (480 - 100) / 2, |
99 100, 100), | 100 100, 100), |
100 window->GetNativeWindow()->bounds()); | 101 window->GetNativeWindow()->bounds()); |
101 widget->CloseNow(); | 102 widget->CloseNow(); |
102 } | 103 } |
103 | 104 |
104 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { | 105 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { |
105 // Make a parent window smaller than the host represented by | 106 // Make a parent window smaller than the host represented by |
106 // WindowEventDispatcher. | 107 // WindowEventDispatcher. |
107 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 108 std::unique_ptr<aura::Window> parent(new aura::Window(NULL)); |
108 parent->Init(ui::LAYER_NOT_DRAWN); | 109 parent->Init(ui::LAYER_NOT_DRAWN); |
109 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); | 110 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); |
110 scoped_ptr<Widget> widget(new Widget()); | 111 std::unique_ptr<Widget> widget(new Widget()); |
111 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 112 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
112 | 113 |
113 window->CenterWindow(gfx::Size(100, 100)); | 114 window->CenterWindow(gfx::Size(100, 100)); |
114 EXPECT_EQ(gfx::Rect( (480 - 100) / 2, | 115 EXPECT_EQ(gfx::Rect( (480 - 100) / 2, |
115 (320 - 100) / 2, | 116 (320 - 100) / 2, |
116 100, 100), | 117 100, 100), |
117 window->GetNativeWindow()->bounds()); | 118 window->GetNativeWindow()->bounds()); |
118 widget->CloseNow(); | 119 widget->CloseNow(); |
119 } | 120 } |
120 | 121 |
121 // Verifies CenterWindow() constrains to parent size. | 122 // Verifies CenterWindow() constrains to parent size. |
122 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) { | 123 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) { |
123 // Make a parent window smaller than the host represented by | 124 // Make a parent window smaller than the host represented by |
124 // WindowEventDispatcher and offset it slightly from the origin. | 125 // WindowEventDispatcher and offset it slightly from the origin. |
125 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 126 std::unique_ptr<aura::Window> parent(new aura::Window(NULL)); |
126 parent->Init(ui::LAYER_NOT_DRAWN); | 127 parent->Init(ui::LAYER_NOT_DRAWN); |
127 parent->SetBounds(gfx::Rect(20, 40, 480, 320)); | 128 parent->SetBounds(gfx::Rect(20, 40, 480, 320)); |
128 scoped_ptr<Widget> widget(new Widget()); | 129 std::unique_ptr<Widget> widget(new Widget()); |
129 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 130 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
130 window->CenterWindow(gfx::Size(500, 600)); | 131 window->CenterWindow(gfx::Size(500, 600)); |
131 | 132 |
132 // |window| should be no bigger than |parent|. | 133 // |window| should be no bigger than |parent|. |
133 EXPECT_EQ("20,40 480x320", window->GetNativeWindow()->bounds().ToString()); | 134 EXPECT_EQ("20,40 480x320", window->GetNativeWindow()->bounds().ToString()); |
134 widget->CloseNow(); | 135 widget->CloseNow(); |
135 } | 136 } |
136 | 137 |
137 TEST_F(NativeWidgetAuraTest, CreateMinimized) { | 138 TEST_F(NativeWidgetAuraTest, CreateMinimized) { |
138 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 139 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
139 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 140 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
140 params.parent = NULL; | 141 params.parent = NULL; |
141 params.context = root_window(); | 142 params.context = root_window(); |
142 params.show_state = ui::SHOW_STATE_MINIMIZED; | 143 params.show_state = ui::SHOW_STATE_MINIMIZED; |
143 params.bounds.SetRect(0, 0, 1024, 800); | 144 params.bounds.SetRect(0, 0, 1024, 800); |
144 scoped_ptr<Widget> widget(new Widget()); | 145 std::unique_ptr<Widget> widget(new Widget()); |
145 widget->Init(params); | 146 widget->Init(params); |
146 widget->Show(); | 147 widget->Show(); |
147 | 148 |
148 EXPECT_TRUE(widget->IsMinimized()); | 149 EXPECT_TRUE(widget->IsMinimized()); |
149 widget->CloseNow(); | 150 widget->CloseNow(); |
150 } | 151 } |
151 | 152 |
152 class TestLayoutManagerBase : public aura::LayoutManager { | 153 class TestLayoutManagerBase : public aura::LayoutManager { |
153 public: | 154 public: |
154 TestLayoutManagerBase() {} | 155 TestLayoutManagerBase() {} |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 DISALLOW_COPY_AND_ASSIGN(TestWidget); | 213 DISALLOW_COPY_AND_ASSIGN(TestWidget); |
213 }; | 214 }; |
214 | 215 |
215 // Verifies the size of the widget doesn't change more than once during Init if | 216 // Verifies the size of the widget doesn't change more than once during Init if |
216 // the window ends up maximized. This is important as otherwise | 217 // the window ends up maximized. This is important as otherwise |
217 // RenderWidgetHostViewAura ends up getting resized during construction, which | 218 // RenderWidgetHostViewAura ends up getting resized during construction, which |
218 // leads to noticable flashes. | 219 // leads to noticable flashes. |
219 TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) { | 220 TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) { |
220 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480)); | 221 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480)); |
221 root_window()->SetLayoutManager(new MaximizeLayoutManager); | 222 root_window()->SetLayoutManager(new MaximizeLayoutManager); |
222 scoped_ptr<TestWidget> widget(new TestWidget()); | 223 std::unique_ptr<TestWidget> widget(new TestWidget()); |
223 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 224 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
224 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 225 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
225 params.parent = NULL; | 226 params.parent = NULL; |
226 params.context = root_window(); | 227 params.context = root_window(); |
227 params.show_state = ui::SHOW_STATE_MAXIMIZED; | 228 params.show_state = ui::SHOW_STATE_MAXIMIZED; |
228 params.bounds = gfx::Rect(10, 10, 100, 200); | 229 params.bounds = gfx::Rect(10, 10, 100, 200); |
229 widget->Init(params); | 230 widget->Init(params); |
230 EXPECT_FALSE(widget->did_size_change_more_than_once()); | 231 EXPECT_FALSE(widget->did_size_change_more_than_once()); |
231 widget->CloseNow(); | 232 widget->CloseNow(); |
232 } | 233 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 Widget* widget_; | 270 Widget* widget_; |
270 DISALLOW_COPY_AND_ASSIGN(PropertyTestWidgetDelegate); | 271 DISALLOW_COPY_AND_ASSIGN(PropertyTestWidgetDelegate); |
271 }; | 272 }; |
272 | 273 |
273 // Verifies that the kCanMaximizeKey/kCanMinimizeKey/kCanResizeKey have the | 274 // Verifies that the kCanMaximizeKey/kCanMinimizeKey/kCanResizeKey have the |
274 // correct value when added to the layout manager. | 275 // correct value when added to the layout manager. |
275 TEST_F(NativeWidgetAuraTest, TestPropertiesWhenAddedToLayout) { | 276 TEST_F(NativeWidgetAuraTest, TestPropertiesWhenAddedToLayout) { |
276 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480)); | 277 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480)); |
277 PropertyTestLayoutManager* layout_manager = new PropertyTestLayoutManager(); | 278 PropertyTestLayoutManager* layout_manager = new PropertyTestLayoutManager(); |
278 root_window()->SetLayoutManager(layout_manager); | 279 root_window()->SetLayoutManager(layout_manager); |
279 scoped_ptr<TestWidget> widget(new TestWidget()); | 280 std::unique_ptr<TestWidget> widget(new TestWidget()); |
280 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 281 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
281 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 282 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
282 params.delegate = new PropertyTestWidgetDelegate(widget.get()); | 283 params.delegate = new PropertyTestWidgetDelegate(widget.get()); |
283 params.parent = NULL; | 284 params.parent = NULL; |
284 params.context = root_window(); | 285 params.context = root_window(); |
285 widget->Init(params); | 286 widget->Init(params); |
286 EXPECT_TRUE(layout_manager->added()); | 287 EXPECT_TRUE(layout_manager->added()); |
287 widget->CloseNow(); | 288 widget->CloseNow(); |
288 } | 289 } |
289 | 290 |
290 TEST_F(NativeWidgetAuraTest, GetClientAreaScreenBounds) { | 291 TEST_F(NativeWidgetAuraTest, GetClientAreaScreenBounds) { |
291 // Create a widget. | 292 // Create a widget. |
292 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 293 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
293 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 294 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
294 params.context = root_window(); | 295 params.context = root_window(); |
295 params.bounds.SetRect(10, 20, 300, 400); | 296 params.bounds.SetRect(10, 20, 300, 400); |
296 scoped_ptr<Widget> widget(new Widget()); | 297 std::unique_ptr<Widget> widget(new Widget()); |
297 widget->Init(params); | 298 widget->Init(params); |
298 | 299 |
299 // For Aura, client area bounds match window bounds. | 300 // For Aura, client area bounds match window bounds. |
300 gfx::Rect client_bounds = widget->GetClientAreaBoundsInScreen(); | 301 gfx::Rect client_bounds = widget->GetClientAreaBoundsInScreen(); |
301 EXPECT_EQ(10, client_bounds.x()); | 302 EXPECT_EQ(10, client_bounds.x()); |
302 EXPECT_EQ(20, client_bounds.y()); | 303 EXPECT_EQ(20, client_bounds.y()); |
303 EXPECT_EQ(300, client_bounds.width()); | 304 EXPECT_EQ(300, client_bounds.width()); |
304 EXPECT_EQ(400, client_bounds.height()); | 305 EXPECT_EQ(400, client_bounds.height()); |
305 } | 306 } |
306 | 307 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // Verifies a capture isn't set on touch press and that the view that gets | 343 // Verifies a capture isn't set on touch press and that the view that gets |
343 // the press gets the release. | 344 // the press gets the release. |
344 TEST_F(NativeWidgetAuraTest, DontCaptureOnGesture) { | 345 TEST_F(NativeWidgetAuraTest, DontCaptureOnGesture) { |
345 // Create two views (both sized the same). |child| is configured not to | 346 // Create two views (both sized the same). |child| is configured not to |
346 // consume the gesture event. | 347 // consume the gesture event. |
347 GestureTrackingView* view = new GestureTrackingView(); | 348 GestureTrackingView* view = new GestureTrackingView(); |
348 GestureTrackingView* child = new GestureTrackingView(); | 349 GestureTrackingView* child = new GestureTrackingView(); |
349 child->set_consume_gesture_event(false); | 350 child->set_consume_gesture_event(false); |
350 view->SetLayoutManager(new FillLayout); | 351 view->SetLayoutManager(new FillLayout); |
351 view->AddChildView(child); | 352 view->AddChildView(child); |
352 scoped_ptr<TestWidget> widget(new TestWidget()); | 353 std::unique_ptr<TestWidget> widget(new TestWidget()); |
353 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 354 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
354 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 355 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
355 params.context = root_window(); | 356 params.context = root_window(); |
356 params.bounds = gfx::Rect(0, 0, 100, 200); | 357 params.bounds = gfx::Rect(0, 0, 100, 200); |
357 widget->Init(params); | 358 widget->Init(params); |
358 widget->SetContentsView(view); | 359 widget->SetContentsView(view); |
359 widget->Show(); | 360 widget->Show(); |
360 | 361 |
361 ui::TouchEvent press( | 362 ui::TouchEvent press( |
362 ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, ui::EventTimeForNow()); | 363 ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, ui::EventTimeForNow()); |
(...skipping 20 matching lines...) Expand all Loading... |
383 | 384 |
384 // Work around for bug in NativeWidgetAura. | 385 // Work around for bug in NativeWidgetAura. |
385 // TODO: fix bug and remove this. | 386 // TODO: fix bug and remove this. |
386 widget->Close(); | 387 widget->Close(); |
387 } | 388 } |
388 | 389 |
389 // Verifies views with layers are targeted for events properly. | 390 // Verifies views with layers are targeted for events properly. |
390 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) { | 391 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) { |
391 // Create two widgets: |parent| and |child|. |child| is a child of |parent|. | 392 // Create two widgets: |parent| and |child|. |child| is a child of |parent|. |
392 views::View* parent_root = new views::View; | 393 views::View* parent_root = new views::View; |
393 scoped_ptr<Widget> parent(new Widget()); | 394 std::unique_ptr<Widget> parent(new Widget()); |
394 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 395 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
395 parent_params.ownership = | 396 parent_params.ownership = |
396 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 397 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
397 parent_params.context = root_window(); | 398 parent_params.context = root_window(); |
398 parent->Init(parent_params); | 399 parent->Init(parent_params); |
399 parent->SetContentsView(parent_root); | 400 parent->SetContentsView(parent_root); |
400 parent->SetBounds(gfx::Rect(0, 0, 400, 400)); | 401 parent->SetBounds(gfx::Rect(0, 0, 400, 400)); |
401 parent->Show(); | 402 parent->Show(); |
402 | 403 |
403 scoped_ptr<Widget> child(new Widget()); | 404 std::unique_ptr<Widget> child(new Widget()); |
404 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); | 405 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); |
405 child_params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 406 child_params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
406 child_params.parent = parent->GetNativeWindow(); | 407 child_params.parent = parent->GetNativeWindow(); |
407 child->Init(child_params); | 408 child->Init(child_params); |
408 child->SetBounds(gfx::Rect(0, 0, 200, 200)); | 409 child->SetBounds(gfx::Rect(0, 0, 200, 200)); |
409 child->Show(); | 410 child->Show(); |
410 | 411 |
411 // Point is over |child|. | 412 // Point is over |child|. |
412 EXPECT_EQ(child->GetNativeWindow(), | 413 EXPECT_EQ(child->GetNativeWindow(), |
413 parent->GetNativeWindow()->GetEventHandlerForPoint( | 414 parent->GetNativeWindow()->GetEventHandlerForPoint( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 gfx::Point(20, 20))); | 446 gfx::Point(20, 20))); |
446 | 447 |
447 // Work around for bug in NativeWidgetAura. | 448 // Work around for bug in NativeWidgetAura. |
448 // TODO: fix bug and remove this. | 449 // TODO: fix bug and remove this. |
449 parent->Close(); | 450 parent->Close(); |
450 } | 451 } |
451 | 452 |
452 // Verifies that widget->FlashFrame() sets aura::client::kDrawAttentionKey, | 453 // Verifies that widget->FlashFrame() sets aura::client::kDrawAttentionKey, |
453 // and activating the window clears it. | 454 // and activating the window clears it. |
454 TEST_F(NativeWidgetAuraTest, FlashFrame) { | 455 TEST_F(NativeWidgetAuraTest, FlashFrame) { |
455 scoped_ptr<Widget> widget(new Widget()); | 456 std::unique_ptr<Widget> widget(new Widget()); |
456 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 457 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
457 params.context = root_window(); | 458 params.context = root_window(); |
458 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 459 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
459 widget->Init(params); | 460 widget->Init(params); |
460 aura::Window* window = widget->GetNativeWindow(); | 461 aura::Window* window = widget->GetNativeWindow(); |
461 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); | 462 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); |
462 widget->FlashFrame(true); | 463 widget->FlashFrame(true); |
463 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); | 464 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); |
464 widget->FlashFrame(false); | 465 widget->FlashFrame(false); |
465 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); | 466 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); |
466 widget->FlashFrame(true); | 467 widget->FlashFrame(true); |
467 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); | 468 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); |
468 widget->Activate(); | 469 widget->Activate(); |
469 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); | 470 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); |
470 } | 471 } |
471 | 472 |
472 TEST_F(NativeWidgetAuraTest, NoCrashOnThemeAfterClose) { | 473 TEST_F(NativeWidgetAuraTest, NoCrashOnThemeAfterClose) { |
473 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 474 std::unique_ptr<aura::Window> parent(new aura::Window(NULL)); |
474 parent->Init(ui::LAYER_NOT_DRAWN); | 475 parent->Init(ui::LAYER_NOT_DRAWN); |
475 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); | 476 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); |
476 scoped_ptr<Widget> widget(new Widget()); | 477 std::unique_ptr<Widget> widget(new Widget()); |
477 Init(parent.get(), widget.get()); | 478 Init(parent.get(), widget.get()); |
478 widget->Show(); | 479 widget->Show(); |
479 widget->Close(); | 480 widget->Close(); |
480 base::MessageLoop::current()->RunUntilIdle(); | 481 base::MessageLoop::current()->RunUntilIdle(); |
481 widget->GetNativeTheme(); // Shouldn't crash. | 482 widget->GetNativeTheme(); // Shouldn't crash. |
482 } | 483 } |
483 | 484 |
484 // Used to track calls to WidgetDelegate::OnWidgetMove(). | 485 // Used to track calls to WidgetDelegate::OnWidgetMove(). |
485 class MoveTestWidgetDelegate : public WidgetDelegateView { | 486 class MoveTestWidgetDelegate : public WidgetDelegateView { |
486 public: | 487 public: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 EXPECT_FALSE(delegate.view()->HasFocus()); | 530 EXPECT_FALSE(delegate.view()->HasFocus()); |
530 | 531 |
531 test_focus_rules()->set_can_activate(true); | 532 test_focus_rules()->set_can_activate(true); |
532 views::test::TestInitialFocusWidgetDelegate delegate2(root_window()); | 533 views::test::TestInitialFocusWidgetDelegate delegate2(root_window()); |
533 delegate2.GetWidget()->Show(); | 534 delegate2.GetWidget()->Show(); |
534 EXPECT_TRUE(delegate2.view()->HasFocus()); | 535 EXPECT_TRUE(delegate2.view()->HasFocus()); |
535 } | 536 } |
536 | 537 |
537 } // namespace | 538 } // namespace |
538 } // namespace views | 539 } // namespace views |
OLD | NEW |