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

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

Powered by Google App Engine
This is Rietveld 408576698