Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: ui/aura/window_unittest.cc

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for added files Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 RunAllPendingInMessageLoop(); 1032 RunAllPendingInMessageLoop();
1033 1033
1034 EXPECT_FALSE(window->HasCapture()); 1034 EXPECT_FALSE(window->HasCapture());
1035 1035
1036 // Do a capture. 1036 // Do a capture.
1037 delegate.ResetCounts(); 1037 delegate.ResetCounts();
1038 window->SetCapture(); 1038 window->SetCapture();
1039 EXPECT_TRUE(window->HasCapture()); 1039 EXPECT_TRUE(window->HasCapture());
1040 EXPECT_EQ(0, delegate.capture_lost_count()); 1040 EXPECT_EQ(0, delegate.capture_lost_count());
1041 EXPECT_EQ(0, delegate.capture_changed_event_count()); 1041 EXPECT_EQ(0, delegate.capture_changed_event_count());
1042 EventGenerator generator(root_window(), gfx::Point(50, 50)); 1042 ui::test::EventGenerator generator(root_window(), gfx::Point(50, 50));
1043 generator.PressLeftButton(); 1043 generator.PressLeftButton();
1044 EXPECT_EQ(0, delegate.capture_lost_count()); 1044 EXPECT_EQ(0, delegate.capture_lost_count());
1045 EXPECT_EQ(0, delegate.capture_changed_event_count()); 1045 EXPECT_EQ(0, delegate.capture_changed_event_count());
1046 EXPECT_EQ(1, delegate.mouse_event_count()); 1046 EXPECT_EQ(1, delegate.mouse_event_count());
1047 1047
1048 // Set capture to |w2|, should implicitly unset capture for |window|. 1048 // Set capture to |w2|, should implicitly unset capture for |window|.
1049 delegate.ResetCounts(); 1049 delegate.ResetCounts();
1050 delegate2.ResetCounts(); 1050 delegate2.ResetCounts();
1051 w2->SetCapture(); 1051 w2->SetCapture();
1052 1052
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 TEST_F(WindowTest, MouseEnterExit) { 1135 TEST_F(WindowTest, MouseEnterExit) {
1136 MouseEnterExitWindowDelegate d1; 1136 MouseEnterExitWindowDelegate d1;
1137 scoped_ptr<Window> w1( 1137 scoped_ptr<Window> w1(
1138 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), 1138 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50),
1139 root_window())); 1139 root_window()));
1140 MouseEnterExitWindowDelegate d2; 1140 MouseEnterExitWindowDelegate d2;
1141 scoped_ptr<Window> w2( 1141 scoped_ptr<Window> w2(
1142 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), 1142 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50),
1143 root_window())); 1143 root_window()));
1144 1144
1145 test::EventGenerator generator(root_window()); 1145 ui::test::EventGenerator generator(root_window());
1146 generator.MoveMouseToCenterOf(w1.get()); 1146 generator.MoveMouseToCenterOf(w1.get());
1147 EXPECT_TRUE(d1.entered()); 1147 EXPECT_TRUE(d1.entered());
1148 EXPECT_FALSE(d1.exited()); 1148 EXPECT_FALSE(d1.exited());
1149 EXPECT_FALSE(d2.entered()); 1149 EXPECT_FALSE(d2.entered());
1150 EXPECT_FALSE(d2.exited()); 1150 EXPECT_FALSE(d2.exited());
1151 1151
1152 generator.MoveMouseToCenterOf(w2.get()); 1152 generator.MoveMouseToCenterOf(w2.get());
1153 EXPECT_TRUE(d1.entered()); 1153 EXPECT_TRUE(d1.entered());
1154 EXPECT_TRUE(d1.exited()); 1154 EXPECT_TRUE(d1.exited());
1155 EXPECT_TRUE(d2.entered()); 1155 EXPECT_TRUE(d2.entered());
1156 EXPECT_FALSE(d2.exited()); 1156 EXPECT_FALSE(d2.exited());
1157 } 1157 }
1158 1158
1159 // Verifies that the WindowDelegate receives MouseExit from ET_MOUSE_EXITED. 1159 // Verifies that the WindowDelegate receives MouseExit from ET_MOUSE_EXITED.
1160 TEST_F(WindowTest, WindowTreeHostExit) { 1160 TEST_F(WindowTest, WindowTreeHostExit) {
1161 MouseEnterExitWindowDelegate d1; 1161 MouseEnterExitWindowDelegate d1;
1162 scoped_ptr<Window> w1( 1162 scoped_ptr<Window> w1(
1163 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), 1163 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50),
1164 root_window())); 1164 root_window()));
1165 1165
1166 test::EventGenerator generator(root_window()); 1166 ui::test::EventGenerator generator(root_window());
1167 generator.MoveMouseToCenterOf(w1.get()); 1167 generator.MoveMouseToCenterOf(w1.get());
1168 EXPECT_TRUE(d1.entered()); 1168 EXPECT_TRUE(d1.entered());
1169 EXPECT_FALSE(d1.exited()); 1169 EXPECT_FALSE(d1.exited());
1170 d1.ResetExpectations(); 1170 d1.ResetExpectations();
1171 1171
1172 ui::MouseEvent exit_event( 1172 ui::MouseEvent exit_event(
1173 ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), 0, 0); 1173 ui::ET_MOUSE_EXITED, gfx::Point(), gfx::Point(), 0, 0);
1174 DispatchEventUsingWindowDispatcher(&exit_event); 1174 DispatchEventUsingWindowDispatcher(&exit_event);
1175 EXPECT_FALSE(d1.entered()); 1175 EXPECT_FALSE(d1.entered());
1176 EXPECT_TRUE(d1.exited()); 1176 EXPECT_TRUE(d1.exited());
1177 } 1177 }
1178 1178
1179 // Verifies that the WindowDelegate receives MouseExit and MouseEnter events for 1179 // Verifies that the WindowDelegate receives MouseExit and MouseEnter events for
1180 // mouse transitions from window to window, even if the entered window sets 1180 // mouse transitions from window to window, even if the entered window sets
1181 // and releases capture. 1181 // and releases capture.
1182 TEST_F(WindowTest, MouseEnterExitWithClick) { 1182 TEST_F(WindowTest, MouseEnterExitWithClick) {
1183 MouseEnterExitWindowDelegate d1; 1183 MouseEnterExitWindowDelegate d1;
1184 scoped_ptr<Window> w1( 1184 scoped_ptr<Window> w1(
1185 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), 1185 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50),
1186 root_window())); 1186 root_window()));
1187 MouseEnterExitWindowDelegate d2; 1187 MouseEnterExitWindowDelegate d2;
1188 scoped_ptr<Window> w2( 1188 scoped_ptr<Window> w2(
1189 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50), 1189 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(70, 70, 50, 50),
1190 root_window())); 1190 root_window()));
1191 1191
1192 test::EventGenerator generator(root_window()); 1192 ui::test::EventGenerator generator(root_window());
1193 generator.MoveMouseToCenterOf(w1.get()); 1193 generator.MoveMouseToCenterOf(w1.get());
1194 EXPECT_TRUE(d1.entered()); 1194 EXPECT_TRUE(d1.entered());
1195 EXPECT_FALSE(d1.exited()); 1195 EXPECT_FALSE(d1.exited());
1196 EXPECT_FALSE(d2.entered()); 1196 EXPECT_FALSE(d2.entered());
1197 EXPECT_FALSE(d2.exited()); 1197 EXPECT_FALSE(d2.exited());
1198 1198
1199 // Emmulate what Views does on a click by grabbing and releasing capture. 1199 // Emmulate what Views does on a click by grabbing and releasing capture.
1200 generator.PressLeftButton(); 1200 generator.PressLeftButton();
1201 w1->SetCapture(); 1201 w1->SetCapture();
1202 w1->ReleaseCapture(); 1202 w1->ReleaseCapture();
1203 generator.ReleaseLeftButton(); 1203 generator.ReleaseLeftButton();
1204 1204
1205 generator.MoveMouseToCenterOf(w2.get()); 1205 generator.MoveMouseToCenterOf(w2.get());
1206 EXPECT_TRUE(d1.entered()); 1206 EXPECT_TRUE(d1.entered());
1207 EXPECT_TRUE(d1.exited()); 1207 EXPECT_TRUE(d1.exited());
1208 EXPECT_TRUE(d2.entered()); 1208 EXPECT_TRUE(d2.entered());
1209 EXPECT_FALSE(d2.exited()); 1209 EXPECT_FALSE(d2.exited());
1210 } 1210 }
1211 1211
1212 TEST_F(WindowTest, MouseEnterExitWhenDeleteWithCapture) { 1212 TEST_F(WindowTest, MouseEnterExitWhenDeleteWithCapture) {
1213 MouseEnterExitWindowDelegate delegate; 1213 MouseEnterExitWindowDelegate delegate;
1214 scoped_ptr<Window> window( 1214 scoped_ptr<Window> window(
1215 CreateTestWindowWithDelegate(&delegate, 1, gfx::Rect(10, 10, 50, 50), 1215 CreateTestWindowWithDelegate(&delegate, 1, gfx::Rect(10, 10, 50, 50),
1216 root_window())); 1216 root_window()));
1217 1217
1218 test::EventGenerator generator(root_window()); 1218 ui::test::EventGenerator generator(root_window());
1219 generator.MoveMouseToCenterOf(window.get()); 1219 generator.MoveMouseToCenterOf(window.get());
1220 EXPECT_TRUE(delegate.entered()); 1220 EXPECT_TRUE(delegate.entered());
1221 EXPECT_FALSE(delegate.exited()); 1221 EXPECT_FALSE(delegate.exited());
1222 1222
1223 // Emmulate what Views does on a click by grabbing and releasing capture. 1223 // Emmulate what Views does on a click by grabbing and releasing capture.
1224 generator.PressLeftButton(); 1224 generator.PressLeftButton();
1225 window->SetCapture(); 1225 window->SetCapture();
1226 1226
1227 delegate.ResetExpectations(); 1227 delegate.ResetExpectations();
1228 generator.MoveMouseTo(0, 0); 1228 generator.MoveMouseTo(0, 0);
1229 EXPECT_FALSE(delegate.entered()); 1229 EXPECT_FALSE(delegate.entered());
1230 EXPECT_FALSE(delegate.exited()); 1230 EXPECT_FALSE(delegate.exited());
1231 1231
1232 delegate.ResetExpectations(); 1232 delegate.ResetExpectations();
1233 window.reset(); 1233 window.reset();
1234 EXPECT_FALSE(delegate.entered()); 1234 EXPECT_FALSE(delegate.entered());
1235 EXPECT_FALSE(delegate.exited()); 1235 EXPECT_FALSE(delegate.exited());
1236 } 1236 }
1237 1237
1238 // Verifies that enter / exits are sent if windows appear and are deleted 1238 // Verifies that enter / exits are sent if windows appear and are deleted
1239 // under the current mouse position.. 1239 // under the current mouse position..
1240 TEST_F(WindowTest, MouseEnterExitWithDelete) { 1240 TEST_F(WindowTest, MouseEnterExitWithDelete) {
1241 MouseEnterExitWindowDelegate d1; 1241 MouseEnterExitWindowDelegate d1;
1242 scoped_ptr<Window> w1( 1242 scoped_ptr<Window> w1(
1243 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), 1243 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50),
1244 root_window())); 1244 root_window()));
1245 1245
1246 test::EventGenerator generator(root_window()); 1246 ui::test::EventGenerator generator(root_window());
1247 generator.MoveMouseToCenterOf(w1.get()); 1247 generator.MoveMouseToCenterOf(w1.get());
1248 EXPECT_TRUE(d1.entered()); 1248 EXPECT_TRUE(d1.entered());
1249 EXPECT_FALSE(d1.exited()); 1249 EXPECT_FALSE(d1.exited());
1250 d1.ResetExpectations(); 1250 d1.ResetExpectations();
1251 1251
1252 MouseEnterExitWindowDelegate d2; 1252 MouseEnterExitWindowDelegate d2;
1253 { 1253 {
1254 scoped_ptr<Window> w2( 1254 scoped_ptr<Window> w2(
1255 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), 1255 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50),
1256 root_window())); 1256 root_window()));
(...skipping 13 matching lines...) Expand all
1270 } 1270 }
1271 1271
1272 // Verifies that enter / exits are sent if windows appear and are hidden 1272 // Verifies that enter / exits are sent if windows appear and are hidden
1273 // under the current mouse position.. 1273 // under the current mouse position..
1274 TEST_F(WindowTest, MouseEnterExitWithHide) { 1274 TEST_F(WindowTest, MouseEnterExitWithHide) {
1275 MouseEnterExitWindowDelegate d1; 1275 MouseEnterExitWindowDelegate d1;
1276 scoped_ptr<Window> w1( 1276 scoped_ptr<Window> w1(
1277 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), 1277 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50),
1278 root_window())); 1278 root_window()));
1279 1279
1280 test::EventGenerator generator(root_window()); 1280 ui::test::EventGenerator generator(root_window());
1281 generator.MoveMouseToCenterOf(w1.get()); 1281 generator.MoveMouseToCenterOf(w1.get());
1282 EXPECT_TRUE(d1.entered()); 1282 EXPECT_TRUE(d1.entered());
1283 EXPECT_FALSE(d1.exited()); 1283 EXPECT_FALSE(d1.exited());
1284 1284
1285 MouseEnterExitWindowDelegate d2; 1285 MouseEnterExitWindowDelegate d2;
1286 scoped_ptr<Window> w2( 1286 scoped_ptr<Window> w2(
1287 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), 1287 CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50),
1288 root_window())); 1288 root_window()));
1289 // Enters / exits can be send asynchronously. 1289 // Enters / exits can be send asynchronously.
1290 RunAllPendingInMessageLoop(); 1290 RunAllPendingInMessageLoop();
(...skipping 11 matching lines...) Expand all
1302 } 1302 }
1303 1303
1304 TEST_F(WindowTest, MouseEnterExitWithParentHide) { 1304 TEST_F(WindowTest, MouseEnterExitWithParentHide) {
1305 MouseEnterExitWindowDelegate d1; 1305 MouseEnterExitWindowDelegate d1;
1306 scoped_ptr<Window> w1( 1306 scoped_ptr<Window> w1(
1307 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), 1307 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50),
1308 root_window())); 1308 root_window()));
1309 MouseEnterExitWindowDelegate d2; 1309 MouseEnterExitWindowDelegate d2;
1310 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), 1310 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50),
1311 w1.get()); 1311 w1.get());
1312 test::EventGenerator generator(root_window()); 1312 ui::test::EventGenerator generator(root_window());
1313 generator.MoveMouseToCenterOf(w2); 1313 generator.MoveMouseToCenterOf(w2);
1314 // Enters / exits can be send asynchronously. 1314 // Enters / exits can be send asynchronously.
1315 RunAllPendingInMessageLoop(); 1315 RunAllPendingInMessageLoop();
1316 EXPECT_TRUE(d2.entered()); 1316 EXPECT_TRUE(d2.entered());
1317 EXPECT_FALSE(d2.exited()); 1317 EXPECT_FALSE(d2.exited());
1318 1318
1319 d2.ResetExpectations(); 1319 d2.ResetExpectations();
1320 w1->Hide(); 1320 w1->Hide();
1321 RunAllPendingInMessageLoop(); 1321 RunAllPendingInMessageLoop();
1322 EXPECT_FALSE(d2.entered()); 1322 EXPECT_FALSE(d2.entered());
1323 EXPECT_TRUE(d2.exited()); 1323 EXPECT_TRUE(d2.exited());
1324 1324
1325 w1.reset(); 1325 w1.reset();
1326 } 1326 }
1327 1327
1328 TEST_F(WindowTest, MouseEnterExitWithParentDelete) { 1328 TEST_F(WindowTest, MouseEnterExitWithParentDelete) {
1329 MouseEnterExitWindowDelegate d1; 1329 MouseEnterExitWindowDelegate d1;
1330 scoped_ptr<Window> w1( 1330 scoped_ptr<Window> w1(
1331 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), 1331 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50),
1332 root_window())); 1332 root_window()));
1333 MouseEnterExitWindowDelegate d2; 1333 MouseEnterExitWindowDelegate d2;
1334 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50), 1334 Window* w2 = CreateTestWindowWithDelegate(&d2, 2, gfx::Rect(10, 10, 50, 50),
1335 w1.get()); 1335 w1.get());
1336 test::EventGenerator generator(root_window()); 1336 ui::test::EventGenerator generator(root_window());
1337 generator.MoveMouseToCenterOf(w2); 1337 generator.MoveMouseToCenterOf(w2);
1338 1338
1339 // Enters / exits can be send asynchronously. 1339 // Enters / exits can be send asynchronously.
1340 RunAllPendingInMessageLoop(); 1340 RunAllPendingInMessageLoop();
1341 EXPECT_TRUE(d2.entered()); 1341 EXPECT_TRUE(d2.entered());
1342 EXPECT_FALSE(d2.exited()); 1342 EXPECT_FALSE(d2.exited());
1343 1343
1344 d2.ResetExpectations(); 1344 d2.ResetExpectations();
1345 w1.reset(); 1345 w1.reset();
1346 RunAllPendingInMessageLoop(); 1346 RunAllPendingInMessageLoop();
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 client.set_ignore_visibility_changes(true); 2017 client.set_ignore_visibility_changes(true);
2018 window->Hide(); 2018 window->Hide();
2019 EXPECT_FALSE(window->IsVisible()); 2019 EXPECT_FALSE(window->IsVisible());
2020 EXPECT_TRUE(window->layer()->visible()); 2020 EXPECT_TRUE(window->layer()->visible());
2021 } 2021 }
2022 2022
2023 // Tests mouse events on window change. 2023 // Tests mouse events on window change.
2024 TEST_F(WindowTest, MouseEventsOnWindowChange) { 2024 TEST_F(WindowTest, MouseEventsOnWindowChange) {
2025 gfx::Size size = host()->GetBounds().size(); 2025 gfx::Size size = host()->GetBounds().size();
2026 2026
2027 EventGenerator generator(root_window()); 2027 ui::test::EventGenerator generator(root_window());
2028 generator.MoveMouseTo(50, 50); 2028 generator.MoveMouseTo(50, 50);
2029 2029
2030 EventCountDelegate d1; 2030 EventCountDelegate d1;
2031 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1, 2031 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d1, 1,
2032 gfx::Rect(0, 0, 100, 100), root_window())); 2032 gfx::Rect(0, 0, 100, 100), root_window()));
2033 RunAllPendingInMessageLoop(); 2033 RunAllPendingInMessageLoop();
2034 // The format of result is "Enter/Mouse/Leave". 2034 // The format of result is "Enter/Mouse/Leave".
2035 EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset()); 2035 EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset());
2036 2036
2037 // Adding new window. 2037 // Adding new window.
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 3439
3440 EXPECT_TRUE(animator); 3440 EXPECT_TRUE(animator);
3441 EXPECT_FALSE(animator->is_animating()); 3441 EXPECT_FALSE(animator->is_animating());
3442 EXPECT_TRUE(observer.animation_completed()); 3442 EXPECT_TRUE(observer.animation_completed());
3443 EXPECT_FALSE(observer.animation_aborted()); 3443 EXPECT_FALSE(observer.animation_aborted());
3444 animator->RemoveObserver(&observer); 3444 animator->RemoveObserver(&observer);
3445 } 3445 }
3446 3446
3447 } // namespace test 3447 } // namespace test
3448 } // namespace aura 3448 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698