| 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/aura/client/capture_client.h" | 17 #include "ui/aura/client/capture_client.h" |
| 18 #include "ui/aura/client/focus_change_observer.h" | 18 #include "ui/aura/client/focus_change_observer.h" |
| 19 #include "ui/aura/client/visibility_client.h" | 19 #include "ui/aura/client/visibility_client.h" |
| 20 #include "ui/aura/client/window_tree_client.h" | 20 #include "ui/aura/client/window_tree_client.h" |
| 21 #include "ui/aura/test/aura_test_base.h" | 21 #include "ui/aura/test/aura_test_base.h" |
| 22 #include "ui/aura/test/aura_test_utils.h" | 22 #include "ui/aura/test/aura_test_utils.h" |
| 23 #include "ui/aura/test/event_generator.h" | |
| 24 #include "ui/aura/test/test_window_delegate.h" | 23 #include "ui/aura/test/test_window_delegate.h" |
| 25 #include "ui/aura/test/test_windows.h" | 24 #include "ui/aura/test/test_windows.h" |
| 26 #include "ui/aura/test/window_test_api.h" | 25 #include "ui/aura/test/window_test_api.h" |
| 27 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
| 28 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
| 29 #include "ui/aura/window_observer.h" | 28 #include "ui/aura/window_observer.h" |
| 30 #include "ui/aura/window_property.h" | 29 #include "ui/aura/window_property.h" |
| 31 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
| 32 #include "ui/base/hit_test.h" | 31 #include "ui/base/hit_test.h" |
| 33 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
| 34 #include "ui/compositor/layer_animation_observer.h" | 33 #include "ui/compositor/layer_animation_observer.h" |
| 35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 34 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 36 #include "ui/compositor/scoped_layer_animation_settings.h" | 35 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 37 #include "ui/compositor/test/test_layers.h" | 36 #include "ui/compositor/test/test_layers.h" |
| 38 #include "ui/events/event.h" | 37 #include "ui/events/event.h" |
| 39 #include "ui/events/event_utils.h" | 38 #include "ui/events/event_utils.h" |
| 40 #include "ui/events/gestures/gesture_configuration.h" | 39 #include "ui/events/gestures/gesture_configuration.h" |
| 41 #include "ui/events/keycodes/keyboard_codes.h" | 40 #include "ui/events/keycodes/keyboard_codes.h" |
| 41 #include "ui/events/test/event_generator.h" |
| 42 #include "ui/gfx/canvas.h" | 42 #include "ui/gfx/canvas.h" |
| 43 #include "ui/gfx/screen.h" | 43 #include "ui/gfx/screen.h" |
| 44 #include "ui/gfx/skia_util.h" | 44 #include "ui/gfx/skia_util.h" |
| 45 #include "ui/gfx/vector2d.h" | 45 #include "ui/gfx/vector2d.h" |
| 46 | 46 |
| 47 DECLARE_WINDOW_PROPERTY_TYPE(const char*) | 47 DECLARE_WINDOW_PROPERTY_TYPE(const char*) |
| 48 DECLARE_WINDOW_PROPERTY_TYPE(int) | 48 DECLARE_WINDOW_PROPERTY_TYPE(int) |
| 49 | 49 |
| 50 namespace aura { | 50 namespace aura { |
| 51 namespace test { | 51 namespace test { |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 &delegate, 0, gfx::Rect(0, 0, 20, 20), root_window())); | 774 &delegate, 0, gfx::Rect(0, 0, 20, 20), root_window())); |
| 775 EXPECT_FALSE(window->HasCapture()); | 775 EXPECT_FALSE(window->HasCapture()); |
| 776 | 776 |
| 777 delegate.ResetCounts(); | 777 delegate.ResetCounts(); |
| 778 | 778 |
| 779 // Do a capture. | 779 // Do a capture. |
| 780 window->SetCapture(); | 780 window->SetCapture(); |
| 781 EXPECT_TRUE(window->HasCapture()); | 781 EXPECT_TRUE(window->HasCapture()); |
| 782 EXPECT_EQ(0, delegate.capture_lost_count()); | 782 EXPECT_EQ(0, delegate.capture_lost_count()); |
| 783 EXPECT_EQ(0, delegate.capture_changed_event_count()); | 783 EXPECT_EQ(0, delegate.capture_changed_event_count()); |
| 784 EventGenerator generator(root_window(), gfx::Point(50, 50)); | 784 ui::test::EventGenerator generator(root_window(), gfx::Point(50, 50)); |
| 785 generator.PressLeftButton(); | 785 generator.PressLeftButton(); |
| 786 EXPECT_EQ(1, delegate.mouse_event_count()); | 786 EXPECT_EQ(1, delegate.mouse_event_count()); |
| 787 generator.ReleaseLeftButton(); | 787 generator.ReleaseLeftButton(); |
| 788 | 788 |
| 789 EXPECT_EQ(2, delegate.mouse_event_count()); | 789 EXPECT_EQ(2, delegate.mouse_event_count()); |
| 790 delegate.ResetCounts(); | 790 delegate.ResetCounts(); |
| 791 | 791 |
| 792 ui::TouchEvent touchev( | 792 ui::TouchEvent touchev( |
| 793 ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime()); | 793 ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime()); |
| 794 DispatchEventUsingWindowDispatcher(&touchev); | 794 DispatchEventUsingWindowDispatcher(&touchev); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 RunAllPendingInMessageLoop(); | 1026 RunAllPendingInMessageLoop(); |
| 1027 | 1027 |
| 1028 EXPECT_FALSE(window->HasCapture()); | 1028 EXPECT_FALSE(window->HasCapture()); |
| 1029 | 1029 |
| 1030 // Do a capture. | 1030 // Do a capture. |
| 1031 delegate.ResetCounts(); | 1031 delegate.ResetCounts(); |
| 1032 window->SetCapture(); | 1032 window->SetCapture(); |
| 1033 EXPECT_TRUE(window->HasCapture()); | 1033 EXPECT_TRUE(window->HasCapture()); |
| 1034 EXPECT_EQ(0, delegate.capture_lost_count()); | 1034 EXPECT_EQ(0, delegate.capture_lost_count()); |
| 1035 EXPECT_EQ(0, delegate.capture_changed_event_count()); | 1035 EXPECT_EQ(0, delegate.capture_changed_event_count()); |
| 1036 EventGenerator generator(root_window(), gfx::Point(50, 50)); | 1036 ui::test::EventGenerator generator(root_window(), gfx::Point(50, 50)); |
| 1037 generator.PressLeftButton(); | 1037 generator.PressLeftButton(); |
| 1038 EXPECT_EQ(0, delegate.capture_lost_count()); | 1038 EXPECT_EQ(0, delegate.capture_lost_count()); |
| 1039 EXPECT_EQ(0, delegate.capture_changed_event_count()); | 1039 EXPECT_EQ(0, delegate.capture_changed_event_count()); |
| 1040 EXPECT_EQ(1, delegate.mouse_event_count()); | 1040 EXPECT_EQ(1, delegate.mouse_event_count()); |
| 1041 | 1041 |
| 1042 // Set capture to |w2|, should implicitly unset capture for |window|. | 1042 // Set capture to |w2|, should implicitly unset capture for |window|. |
| 1043 delegate.ResetCounts(); | 1043 delegate.ResetCounts(); |
| 1044 delegate2.ResetCounts(); | 1044 delegate2.ResetCounts(); |
| 1045 w2->SetCapture(); | 1045 w2->SetCapture(); |
| 1046 | 1046 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 TEST_F(WindowTest, MouseEnterExit) { | 1129 TEST_F(WindowTest, MouseEnterExit) { |
| 1130 MouseEnterExitWindowDelegate d1; | 1130 MouseEnterExitWindowDelegate d1; |
| 1131 scoped_ptr<Window> w1( | 1131 scoped_ptr<Window> w1( |
| 1132 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), | 1132 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), |
| 1133 root_window())); | 1133 root_window())); |
| 1134 MouseEnterExitWindowDelegate d2; | 1134 MouseEnterExitWindowDelegate d2; |
| 1135 scoped_ptr<Window> w2( | 1135 scoped_ptr<Window> w2( |
| 1136 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), | 1136 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), |
| 1137 root_window())); | 1137 root_window())); |
| 1138 | 1138 |
| 1139 test::EventGenerator generator(root_window()); | 1139 ui::test::EventGenerator generator(root_window()); |
| 1140 generator.MoveMouseToCenterOf(w1.get()); | 1140 generator.MoveMouseToCenterOf(w1.get()); |
| 1141 EXPECT_TRUE(d1.entered()); | 1141 EXPECT_TRUE(d1.entered()); |
| 1142 EXPECT_FALSE(d1.exited()); | 1142 EXPECT_FALSE(d1.exited()); |
| 1143 EXPECT_FALSE(d2.entered()); | 1143 EXPECT_FALSE(d2.entered()); |
| 1144 EXPECT_FALSE(d2.exited()); | 1144 EXPECT_FALSE(d2.exited()); |
| 1145 | 1145 |
| 1146 generator.MoveMouseToCenterOf(w2.get()); | 1146 generator.MoveMouseToCenterOf(w2.get()); |
| 1147 EXPECT_TRUE(d1.entered()); | 1147 EXPECT_TRUE(d1.entered()); |
| 1148 EXPECT_TRUE(d1.exited()); | 1148 EXPECT_TRUE(d1.exited()); |
| 1149 EXPECT_TRUE(d2.entered()); | 1149 EXPECT_TRUE(d2.entered()); |
| 1150 EXPECT_FALSE(d2.exited()); | 1150 EXPECT_FALSE(d2.exited()); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 // Verifies that the WindowDelegate receives MouseExit from ET_MOUSE_EXITED. | 1153 // Verifies that the WindowDelegate receives MouseExit from ET_MOUSE_EXITED. |
| 1154 TEST_F(WindowTest, WindowTreeHostExit) { | 1154 TEST_F(WindowTest, WindowTreeHostExit) { |
| 1155 MouseEnterExitWindowDelegate d1; | 1155 MouseEnterExitWindowDelegate d1; |
| 1156 scoped_ptr<Window> w1( | 1156 scoped_ptr<Window> w1( |
| 1157 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), | 1157 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), |
| 1158 root_window())); | 1158 root_window())); |
| 1159 | 1159 |
| 1160 test::EventGenerator generator(root_window()); | 1160 ui::test::EventGenerator generator(root_window()); |
| 1161 generator.MoveMouseToCenterOf(w1.get()); | 1161 generator.MoveMouseToCenterOf(w1.get()); |
| 1162 EXPECT_TRUE(d1.entered()); | 1162 EXPECT_TRUE(d1.entered()); |
| 1163 EXPECT_FALSE(d1.exited()); | 1163 EXPECT_FALSE(d1.exited()); |
| 1164 d1.ResetExpectations(); | 1164 d1.ResetExpectations(); |
| 1165 | 1165 |
| 1166 ui::MouseEvent exit_event( | 1166 ui::MouseEvent exit_event( |
| 1167 ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), 0, 0); | 1167 ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), 0, 0); |
| 1168 DispatchEventUsingWindowDispatcher(&exit_event); | 1168 DispatchEventUsingWindowDispatcher(&exit_event); |
| 1169 EXPECT_FALSE(d1.entered()); | 1169 EXPECT_FALSE(d1.entered()); |
| 1170 EXPECT_TRUE(d1.exited()); | 1170 EXPECT_TRUE(d1.exited()); |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 // Verifies that the WindowDelegate receives MouseExit and MouseEnter events for | 1173 // Verifies that the WindowDelegate receives MouseExit and MouseEnter events for |
| 1174 // mouse transitions from window to window, even if the entered window sets | 1174 // mouse transitions from window to window, even if the entered window sets |
| 1175 // and releases capture. | 1175 // and releases capture. |
| 1176 TEST_F(WindowTest, MouseEnterExitWithClick) { | 1176 TEST_F(WindowTest, MouseEnterExitWithClick) { |
| 1177 MouseEnterExitWindowDelegate d1; | 1177 MouseEnterExitWindowDelegate d1; |
| 1178 scoped_ptr<Window> w1( | 1178 scoped_ptr<Window> w1( |
| 1179 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), | 1179 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), |
| 1180 root_window())); | 1180 root_window())); |
| 1181 MouseEnterExitWindowDelegate d2; | 1181 MouseEnterExitWindowDelegate d2; |
| 1182 scoped_ptr<Window> w2( | 1182 scoped_ptr<Window> w2( |
| 1183 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), | 1183 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), |
| 1184 root_window())); | 1184 root_window())); |
| 1185 | 1185 |
| 1186 test::EventGenerator generator(root_window()); | 1186 ui::test::EventGenerator generator(root_window()); |
| 1187 generator.MoveMouseToCenterOf(w1.get()); | 1187 generator.MoveMouseToCenterOf(w1.get()); |
| 1188 EXPECT_TRUE(d1.entered()); | 1188 EXPECT_TRUE(d1.entered()); |
| 1189 EXPECT_FALSE(d1.exited()); | 1189 EXPECT_FALSE(d1.exited()); |
| 1190 EXPECT_FALSE(d2.entered()); | 1190 EXPECT_FALSE(d2.entered()); |
| 1191 EXPECT_FALSE(d2.exited()); | 1191 EXPECT_FALSE(d2.exited()); |
| 1192 | 1192 |
| 1193 // Emmulate what Views does on a click by grabbing and releasing capture. | 1193 // Emmulate what Views does on a click by grabbing and releasing capture. |
| 1194 generator.PressLeftButton(); | 1194 generator.PressLeftButton(); |
| 1195 w1->SetCapture(); | 1195 w1->SetCapture(); |
| 1196 w1->ReleaseCapture(); | 1196 w1->ReleaseCapture(); |
| 1197 generator.ReleaseLeftButton(); | 1197 generator.ReleaseLeftButton(); |
| 1198 | 1198 |
| 1199 generator.MoveMouseToCenterOf(w2.get()); | 1199 generator.MoveMouseToCenterOf(w2.get()); |
| 1200 EXPECT_TRUE(d1.entered()); | 1200 EXPECT_TRUE(d1.entered()); |
| 1201 EXPECT_TRUE(d1.exited()); | 1201 EXPECT_TRUE(d1.exited()); |
| 1202 EXPECT_TRUE(d2.entered()); | 1202 EXPECT_TRUE(d2.entered()); |
| 1203 EXPECT_FALSE(d2.exited()); | 1203 EXPECT_FALSE(d2.exited()); |
| 1204 } | 1204 } |
| 1205 | 1205 |
| 1206 TEST_F(WindowTest, MouseEnterExitWhenDeleteWithCapture) { | 1206 TEST_F(WindowTest, MouseEnterExitWhenDeleteWithCapture) { |
| 1207 MouseEnterExitWindowDelegate delegate; | 1207 MouseEnterExitWindowDelegate delegate; |
| 1208 scoped_ptr<Window> window( | 1208 scoped_ptr<Window> window( |
| 1209 CreateTestWindowWithDelegate(&delegate, 1, gfx::Rect(10, 10, 50, 50), | 1209 CreateTestWindowWithDelegate(&delegate, 1, gfx::Rect(10, 10, 50, 50), |
| 1210 root_window())); | 1210 root_window())); |
| 1211 | 1211 |
| 1212 test::EventGenerator generator(root_window()); | 1212 ui::test::EventGenerator generator(root_window()); |
| 1213 generator.MoveMouseToCenterOf(window.get()); | 1213 generator.MoveMouseToCenterOf(window.get()); |
| 1214 EXPECT_TRUE(delegate.entered()); | 1214 EXPECT_TRUE(delegate.entered()); |
| 1215 EXPECT_FALSE(delegate.exited()); | 1215 EXPECT_FALSE(delegate.exited()); |
| 1216 | 1216 |
| 1217 // Emmulate what Views does on a click by grabbing and releasing capture. | 1217 // Emmulate what Views does on a click by grabbing and releasing capture. |
| 1218 generator.PressLeftButton(); | 1218 generator.PressLeftButton(); |
| 1219 window->SetCapture(); | 1219 window->SetCapture(); |
| 1220 | 1220 |
| 1221 delegate.ResetExpectations(); | 1221 delegate.ResetExpectations(); |
| 1222 generator.MoveMouseTo(0, 0); | 1222 generator.MoveMouseTo(0, 0); |
| 1223 EXPECT_FALSE(delegate.entered()); | 1223 EXPECT_FALSE(delegate.entered()); |
| 1224 EXPECT_FALSE(delegate.exited()); | 1224 EXPECT_FALSE(delegate.exited()); |
| 1225 | 1225 |
| 1226 delegate.ResetExpectations(); | 1226 delegate.ResetExpectations(); |
| 1227 window.reset(); | 1227 window.reset(); |
| 1228 EXPECT_FALSE(delegate.entered()); | 1228 EXPECT_FALSE(delegate.entered()); |
| 1229 EXPECT_FALSE(delegate.exited()); | 1229 EXPECT_FALSE(delegate.exited()); |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 // Verifies that enter / exits are sent if windows appear and are deleted | 1232 // Verifies that enter / exits are sent if windows appear and are deleted |
| 1233 // under the current mouse position.. | 1233 // under the current mouse position.. |
| 1234 TEST_F(WindowTest, MouseEnterExitWithDelete) { | 1234 TEST_F(WindowTest, MouseEnterExitWithDelete) { |
| 1235 MouseEnterExitWindowDelegate d1; | 1235 MouseEnterExitWindowDelegate d1; |
| 1236 scoped_ptr<Window> w1( | 1236 scoped_ptr<Window> w1( |
| 1237 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), | 1237 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), |
| 1238 root_window())); | 1238 root_window())); |
| 1239 | 1239 |
| 1240 test::EventGenerator generator(root_window()); | 1240 ui::test::EventGenerator generator(root_window()); |
| 1241 generator.MoveMouseToCenterOf(w1.get()); | 1241 generator.MoveMouseToCenterOf(w1.get()); |
| 1242 EXPECT_TRUE(d1.entered()); | 1242 EXPECT_TRUE(d1.entered()); |
| 1243 EXPECT_FALSE(d1.exited()); | 1243 EXPECT_FALSE(d1.exited()); |
| 1244 d1.ResetExpectations(); | 1244 d1.ResetExpectations(); |
| 1245 | 1245 |
| 1246 MouseEnterExitWindowDelegate d2; | 1246 MouseEnterExitWindowDelegate d2; |
| 1247 { | 1247 { |
| 1248 scoped_ptr<Window> w2( | 1248 scoped_ptr<Window> w2( |
| 1249 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), | 1249 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), |
| 1250 root_window())); | 1250 root_window())); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 // Verifies that enter / exits are sent if windows appear and are hidden | 1266 // Verifies that enter / exits are sent if windows appear and are hidden |
| 1267 // under the current mouse position.. | 1267 // under the current mouse position.. |
| 1268 TEST_F(WindowTest, MouseEnterExitWithHide) { | 1268 TEST_F(WindowTest, MouseEnterExitWithHide) { |
| 1269 MouseEnterExitWindowDelegate d1; | 1269 MouseEnterExitWindowDelegate d1; |
| 1270 scoped_ptr<Window> w1( | 1270 scoped_ptr<Window> w1( |
| 1271 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), | 1271 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), |
| 1272 root_window())); | 1272 root_window())); |
| 1273 | 1273 |
| 1274 test::EventGenerator generator(root_window()); | 1274 ui::test::EventGenerator generator(root_window()); |
| 1275 generator.MoveMouseToCenterOf(w1.get()); | 1275 generator.MoveMouseToCenterOf(w1.get()); |
| 1276 EXPECT_TRUE(d1.entered()); | 1276 EXPECT_TRUE(d1.entered()); |
| 1277 EXPECT_FALSE(d1.exited()); | 1277 EXPECT_FALSE(d1.exited()); |
| 1278 | 1278 |
| 1279 MouseEnterExitWindowDelegate d2; | 1279 MouseEnterExitWindowDelegate d2; |
| 1280 scoped_ptr<Window> w2( | 1280 scoped_ptr<Window> w2( |
| 1281 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), | 1281 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), |
| 1282 root_window())); | 1282 root_window())); |
| 1283 // Enters / exits can be send asynchronously. | 1283 // Enters / exits can be send asynchronously. |
| 1284 RunAllPendingInMessageLoop(); | 1284 RunAllPendingInMessageLoop(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1296 } | 1296 } |
| 1297 | 1297 |
| 1298 TEST_F(WindowTest, MouseEnterExitWithParentHide) { | 1298 TEST_F(WindowTest, MouseEnterExitWithParentHide) { |
| 1299 MouseEnterExitWindowDelegate d1; | 1299 MouseEnterExitWindowDelegate d1; |
| 1300 scoped_ptr<Window> w1( | 1300 scoped_ptr<Window> w1( |
| 1301 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), | 1301 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), |
| 1302 root_window())); | 1302 root_window())); |
| 1303 MouseEnterExitWindowDelegate d2; | 1303 MouseEnterExitWindowDelegate d2; |
| 1304 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), | 1304 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), |
| 1305 w1.get()); | 1305 w1.get()); |
| 1306 test::EventGenerator generator(root_window()); | 1306 ui::test::EventGenerator generator(root_window()); |
| 1307 generator.MoveMouseToCenterOf(w2); | 1307 generator.MoveMouseToCenterOf(w2); |
| 1308 // Enters / exits can be send asynchronously. | 1308 // Enters / exits can be send asynchronously. |
| 1309 RunAllPendingInMessageLoop(); | 1309 RunAllPendingInMessageLoop(); |
| 1310 EXPECT_TRUE(d2.entered()); | 1310 EXPECT_TRUE(d2.entered()); |
| 1311 EXPECT_FALSE(d2.exited()); | 1311 EXPECT_FALSE(d2.exited()); |
| 1312 | 1312 |
| 1313 d2.ResetExpectations(); | 1313 d2.ResetExpectations(); |
| 1314 w1->Hide(); | 1314 w1->Hide(); |
| 1315 RunAllPendingInMessageLoop(); | 1315 RunAllPendingInMessageLoop(); |
| 1316 EXPECT_FALSE(d2.entered()); | 1316 EXPECT_FALSE(d2.entered()); |
| 1317 EXPECT_TRUE(d2.exited()); | 1317 EXPECT_TRUE(d2.exited()); |
| 1318 | 1318 |
| 1319 w1.reset(); | 1319 w1.reset(); |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 TEST_F(WindowTest, MouseEnterExitWithParentDelete) { | 1322 TEST_F(WindowTest, MouseEnterExitWithParentDelete) { |
| 1323 MouseEnterExitWindowDelegate d1; | 1323 MouseEnterExitWindowDelegate d1; |
| 1324 scoped_ptr<Window> w1( | 1324 scoped_ptr<Window> w1( |
| 1325 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), | 1325 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), |
| 1326 root_window())); | 1326 root_window())); |
| 1327 MouseEnterExitWindowDelegate d2; | 1327 MouseEnterExitWindowDelegate d2; |
| 1328 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), | 1328 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), |
| 1329 w1.get()); | 1329 w1.get()); |
| 1330 test::EventGenerator generator(root_window()); | 1330 ui::test::EventGenerator generator(root_window()); |
| 1331 generator.MoveMouseToCenterOf(w2); | 1331 generator.MoveMouseToCenterOf(w2); |
| 1332 | 1332 |
| 1333 // Enters / exits can be send asynchronously. | 1333 // Enters / exits can be send asynchronously. |
| 1334 RunAllPendingInMessageLoop(); | 1334 RunAllPendingInMessageLoop(); |
| 1335 EXPECT_TRUE(d2.entered()); | 1335 EXPECT_TRUE(d2.entered()); |
| 1336 EXPECT_FALSE(d2.exited()); | 1336 EXPECT_FALSE(d2.exited()); |
| 1337 | 1337 |
| 1338 d2.ResetExpectations(); | 1338 d2.ResetExpectations(); |
| 1339 w1.reset(); | 1339 w1.reset(); |
| 1340 RunAllPendingInMessageLoop(); | 1340 RunAllPendingInMessageLoop(); |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 client.set_ignore_visibility_changes(true); | 2011 client.set_ignore_visibility_changes(true); |
| 2012 window->Hide(); | 2012 window->Hide(); |
| 2013 EXPECT_FALSE(window->IsVisible()); | 2013 EXPECT_FALSE(window->IsVisible()); |
| 2014 EXPECT_TRUE(window->layer()->visible()); | 2014 EXPECT_TRUE(window->layer()->visible()); |
| 2015 } | 2015 } |
| 2016 | 2016 |
| 2017 // Tests mouse events on window change. | 2017 // Tests mouse events on window change. |
| 2018 TEST_F(WindowTest, MouseEventsOnWindowChange) { | 2018 TEST_F(WindowTest, MouseEventsOnWindowChange) { |
| 2019 gfx::Size size = host()->GetBounds().size(); | 2019 gfx::Size size = host()->GetBounds().size(); |
| 2020 | 2020 |
| 2021 EventGenerator generator(root_window()); | 2021 ui::test::EventGenerator generator(root_window()); |
| 2022 generator.MoveMouseTo(50, 50); | 2022 generator.MoveMouseTo(50, 50); |
| 2023 | 2023 |
| 2024 EventCountDelegate d1; | 2024 EventCountDelegate d1; |
| 2025 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1, | 2025 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1, |
| 2026 gfx::Rect(0, 0, 100, 100), root_window())); | 2026 gfx::Rect(0, 0, 100, 100), root_window())); |
| 2027 RunAllPendingInMessageLoop(); | 2027 RunAllPendingInMessageLoop(); |
| 2028 // The format of result is "Enter/Mouse/Leave". | 2028 // The format of result is "Enter/Mouse/Leave". |
| 2029 EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset()); | 2029 EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset()); |
| 2030 | 2030 |
| 2031 // Adding new window. | 2031 // Adding new window. |
| (...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3433 | 3433 |
| 3434 EXPECT_TRUE(animator); | 3434 EXPECT_TRUE(animator); |
| 3435 EXPECT_FALSE(animator->is_animating()); | 3435 EXPECT_FALSE(animator->is_animating()); |
| 3436 EXPECT_TRUE(observer.animation_completed()); | 3436 EXPECT_TRUE(observer.animation_completed()); |
| 3437 EXPECT_FALSE(observer.animation_aborted()); | 3437 EXPECT_FALSE(observer.animation_aborted()); |
| 3438 animator->RemoveObserver(&observer); | 3438 animator->RemoveObserver(&observer); |
| 3439 } | 3439 } |
| 3440 | 3440 |
| 3441 } // namespace test | 3441 } // namespace test |
| 3442 } // namespace aura | 3442 } // namespace aura |
| OLD | NEW |