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/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
15 #include "ui/aura/client/focus_change_observer.h" | 15 #include "ui/aura/client/focus_change_observer.h" |
16 #include "ui/aura/client/stacking_client.h" | 16 #include "ui/aura/client/stacking_client.h" |
17 #include "ui/aura/client/visibility_client.h" | 17 #include "ui/aura/client/visibility_client.h" |
18 #include "ui/aura/layout_manager.h" | 18 #include "ui/aura/layout_manager.h" |
19 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
20 #include "ui/aura/root_window_host.h" | 20 #include "ui/aura/root_window_host.h" |
21 #include "ui/aura/root_window_observer.h" | 21 #include "ui/aura/root_window_observer.h" |
22 #include "ui/aura/test/aura_test_base.h" | 22 #include "ui/aura/test/aura_test_base.h" |
23 #include "ui/aura/test/event_generator.h" | 23 #include "ui/aura/test/event_generator.h" |
24 #include "ui/aura/test/test_window_delegate.h" | 24 #include "ui/aura/test/test_window_delegate.h" |
25 #include "ui/aura/test/test_windows.h" | 25 #include "ui/aura/test/test_windows.h" |
| 26 #include "ui/aura/test/window_test_api.h" |
26 #include "ui/aura/window_delegate.h" | 27 #include "ui/aura/window_delegate.h" |
27 #include "ui/aura/window_observer.h" | 28 #include "ui/aura/window_observer.h" |
28 #include "ui/aura/window_property.h" | 29 #include "ui/aura/window_property.h" |
29 #include "ui/base/events/event.h" | 30 #include "ui/base/events/event.h" |
30 #include "ui/base/events/event_utils.h" | 31 #include "ui/base/events/event_utils.h" |
31 #include "ui/base/gestures/gesture_configuration.h" | 32 #include "ui/base/gestures/gesture_configuration.h" |
32 #include "ui/base/hit_test.h" | 33 #include "ui/base/hit_test.h" |
33 #include "ui/base/keycodes/keyboard_codes.h" | 34 #include "ui/base/keycodes/keyboard_codes.h" |
34 #include "ui/compositor/layer.h" | 35 #include "ui/compositor/layer.h" |
35 #include "ui/compositor/scoped_layer_animation_settings.h" | 36 #include "ui/compositor/scoped_layer_animation_settings.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 w1111->MoveCursorTo(gfx::Point(10, 10)); | 368 w1111->MoveCursorTo(gfx::Point(10, 10)); |
368 EXPECT_EQ("35,35", | 369 EXPECT_EQ("35,35", |
369 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); | 370 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); |
370 } | 371 } |
371 | 372 |
372 TEST_F(WindowTest, ContainsMouse) { | 373 TEST_F(WindowTest, ContainsMouse) { |
373 scoped_ptr<Window> w( | 374 scoped_ptr<Window> w( |
374 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), | 375 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), |
375 root_window())); | 376 root_window())); |
376 w->Show(); | 377 w->Show(); |
377 Window::TestApi w_test_api(w.get()); | 378 WindowTestApi w_test_api(w.get()); |
378 RootWindow* root = root_window(); | 379 RootWindow* root = root_window(); |
379 root->MoveCursorTo(gfx::Point(10, 10)); | 380 root->MoveCursorTo(gfx::Point(10, 10)); |
380 EXPECT_TRUE(w_test_api.ContainsMouse()); | 381 EXPECT_TRUE(w_test_api.ContainsMouse()); |
381 root->MoveCursorTo(gfx::Point(9, 10)); | 382 root->MoveCursorTo(gfx::Point(9, 10)); |
382 EXPECT_FALSE(w_test_api.ContainsMouse()); | 383 EXPECT_FALSE(w_test_api.ContainsMouse()); |
383 } | 384 } |
384 | 385 |
385 // Test Window::ConvertPointToWindow() with transform to root_window. | 386 // Test Window::ConvertPointToWindow() with transform to root_window. |
386 TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { | 387 TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { |
387 RootWindow* root = root_window(); | 388 RootWindow* root = root_window(); |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 EXPECT_EQ(PropertyChangeInfo( | 1859 EXPECT_EQ(PropertyChangeInfo( |
1859 reinterpret_cast<const void*>(NULL), -3), PropertyChangeInfoAndClear()); | 1860 reinterpret_cast<const void*>(NULL), -3), PropertyChangeInfoAndClear()); |
1860 } | 1861 } |
1861 | 1862 |
1862 TEST_F(WindowTest, AcquireLayer) { | 1863 TEST_F(WindowTest, AcquireLayer) { |
1863 scoped_ptr<Window> window1(CreateTestWindowWithId(1, root_window())); | 1864 scoped_ptr<Window> window1(CreateTestWindowWithId(1, root_window())); |
1864 scoped_ptr<Window> window2(CreateTestWindowWithId(2, root_window())); | 1865 scoped_ptr<Window> window2(CreateTestWindowWithId(2, root_window())); |
1865 ui::Layer* parent = window1->parent()->layer(); | 1866 ui::Layer* parent = window1->parent()->layer(); |
1866 EXPECT_EQ(2U, parent->children().size()); | 1867 EXPECT_EQ(2U, parent->children().size()); |
1867 | 1868 |
1868 Window::TestApi window1_test_api(window1.get()); | 1869 WindowTestApi window1_test_api(window1.get()); |
1869 Window::TestApi window2_test_api(window2.get()); | 1870 WindowTestApi window2_test_api(window2.get()); |
1870 | 1871 |
1871 EXPECT_TRUE(window1_test_api.OwnsLayer()); | 1872 EXPECT_TRUE(window1_test_api.OwnsLayer()); |
1872 EXPECT_TRUE(window2_test_api.OwnsLayer()); | 1873 EXPECT_TRUE(window2_test_api.OwnsLayer()); |
1873 | 1874 |
1874 // After acquisition, window1 should not own its layer, but it should still | 1875 // After acquisition, window1 should not own its layer, but it should still |
1875 // be available to the window. | 1876 // be available to the window. |
1876 scoped_ptr<ui::Layer> window1_layer(window1->AcquireLayer()); | 1877 scoped_ptr<ui::Layer> window1_layer(window1->AcquireLayer()); |
1877 EXPECT_FALSE(window1_test_api.OwnsLayer()); | 1878 EXPECT_FALSE(window1_test_api.OwnsLayer()); |
1878 EXPECT_TRUE(window1_layer.get() == window1->layer()); | 1879 EXPECT_TRUE(window1_layer.get() == window1->layer()); |
1879 | 1880 |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2842 o.ValidateState(index++, params); | 2843 o.ValidateState(index++, params); |
2843 | 2844 |
2844 w1.reset(); | 2845 w1.reset(); |
2845 w2.reset(); | 2846 w2.reset(); |
2846 } | 2847 } |
2847 | 2848 |
2848 } | 2849 } |
2849 | 2850 |
2850 } // namespace test | 2851 } // namespace test |
2851 } // namespace aura | 2852 } // namespace aura |
OLD | NEW |