Chromium Code Reviews| 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 "ash/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1249 ShelfButton* button = GetButtonByID(last_added); | 1249 ShelfButton* button = GetButtonByID(last_added); |
| 1250 ASSERT_EQ(ShelfButton::STATE_RUNNING, button->state()); | 1250 ASSERT_EQ(ShelfButton::STATE_RUNNING, button->state()); |
| 1251 item.status = STATUS_ACTIVE; | 1251 item.status = STATUS_ACTIVE; |
| 1252 model_->Set(index, item); | 1252 model_->Set(index, item); |
| 1253 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); | 1253 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); |
| 1254 item.status = STATUS_ATTENTION; | 1254 item.status = STATUS_ATTENTION; |
| 1255 model_->Set(index, item); | 1255 model_->Set(index, item); |
| 1256 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); | 1256 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 // Test that certain drag movements will rip or not rip off the app from the | |
|
msw
2017/06/06 00:27:23
nit: "Test what drag movements will rip an item of
sammiequon
2017/06/06 16:21:26
Done.
| |
| 1260 // shelf. | |
| 1261 TEST_F(ShelfViewTest, ShelfRipOff) { | |
| 1262 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1263 | |
| 1264 // The test makes some assumptions that the shelf is bottom aligned. | |
| 1265 ASSERT_EQ(test_api_->shelf_view()->shelf()->alignment(), | |
| 1266 SHELF_ALIGNMENT_BOTTOM); | |
| 1267 | |
| 1268 // The rip off threshold. Taken from |kRipOffDistance| in shelf_view.cc. | |
| 1269 const int kRipOffDistance = 48; | |
| 1270 | |
| 1271 // Add two apps (which is on the main shelf) and then add buttons until | |
| 1272 // overflow. Add one more app (which is on the overflow shelf). | |
| 1273 ShelfID first_app_id = AddAppShortcut(); | |
| 1274 ShelfID second_app_id = AddAppShortcut(); | |
| 1275 AddButtonsUntilOverflow(); | |
| 1276 ShelfID overflow_app_id = AddAppShortcut(); | |
| 1277 | |
| 1278 // Verify that dragging an app off the shelf will trigger the app getting | |
| 1279 // ripped off, unless the distance is less than |kRipOffDistance|. | |
| 1280 gfx::Point first_app_location = GetButtonCenter(GetButtonByID(first_app_id)); | |
| 1281 generator.set_current_location(first_app_location); | |
| 1282 generator.PressLeftButton(); | |
| 1283 // Drag the mouse to just off the shelf. | |
| 1284 generator.MoveMouseBy(0, -kShelfSize / 2 - 1); | |
| 1285 EXPECT_FALSE(test_api_->IsRippedOffFromShelf()); | |
| 1286 // Drag the mouse past the rip off threshold. | |
| 1287 generator.MoveMouseBy(0, -kRipOffDistance); | |
| 1288 EXPECT_TRUE(test_api_->IsRippedOffFromShelf()); | |
| 1289 // Drag the mouse back to the original position, so that the app does not get | |
| 1290 // deleted. | |
| 1291 generator.MoveMouseTo(first_app_location); | |
| 1292 generator.ReleaseLeftButton(); | |
| 1293 EXPECT_FALSE(test_api_->IsRippedOffFromShelf()); | |
| 1294 | |
| 1295 // Open overflow shelf and test api for it. | |
| 1296 test_api_->ShowOverflowBubble(); | |
| 1297 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | |
| 1298 ShelfViewTestAPI test_api_for_overflow( | |
| 1299 test_api_->overflow_bubble()->shelf_view()); | |
| 1300 | |
| 1301 // Verify that when an app from the main shelf is dragged to a location on the | |
| 1302 // overflow shelf, it is ripped off. | |
| 1303 gfx::Point second_app_location = | |
| 1304 GetButtonCenter(GetButtonByID(second_app_id)); | |
| 1305 gfx::Point overflow_app_location = GetButtonCenter( | |
| 1306 test_api_for_overflow.GetButton(model_->ItemIndexByID(overflow_app_id))); | |
| 1307 generator.set_current_location(second_app_location); | |
| 1308 generator.PressLeftButton(); | |
| 1309 generator.MoveMouseTo(overflow_app_location); | |
| 1310 EXPECT_TRUE(test_api_->IsRippedOffFromShelf()); | |
| 1311 generator.MoveMouseTo(second_app_location); | |
| 1312 generator.ReleaseLeftButton(); | |
| 1313 EXPECT_FALSE(test_api_->IsRippedOffFromShelf()); | |
| 1314 | |
| 1315 // Verify that when an app from the overflow shelf is dragged to a location on | |
| 1316 // the main shelf, it is ripped off. | |
| 1317 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | |
| 1318 generator.set_current_location(overflow_app_location); | |
| 1319 generator.PressLeftButton(); | |
| 1320 generator.MoveMouseTo(second_app_location); | |
| 1321 EXPECT_TRUE(test_api_for_overflow.IsRippedOffFromShelf()); | |
| 1322 generator.MoveMouseTo(overflow_app_location); | |
| 1323 generator.ReleaseLeftButton(); | |
| 1324 EXPECT_FALSE(test_api_for_overflow.IsRippedOffFromShelf()); | |
| 1325 } | |
| 1326 | |
| 1259 // Confirm that item status changes are reflected in the buttons | 1327 // Confirm that item status changes are reflected in the buttons |
| 1260 // for platform apps. | 1328 // for platform apps. |
| 1261 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { | 1329 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { |
| 1262 // All buttons should be visible. | 1330 // All buttons should be visible. |
| 1263 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); | 1331 ASSERT_EQ(test_api_->GetButtonCount(), test_api_->GetLastVisibleIndex() + 1); |
| 1264 | 1332 |
| 1265 // Add platform app button. | 1333 // Add platform app button. |
| 1266 ShelfID last_added = AddApp(); | 1334 ShelfID last_added = AddApp(); |
| 1267 ShelfItem item = GetItemByID(last_added); | 1335 ShelfItem item = GetItemByID(last_added); |
| 1268 int index = model_->ItemIndexByID(last_added); | 1336 int index = model_->ItemIndexByID(last_added); |
| (...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3134 EXPECT_EQ(views::InkDropState::ACTIVATED, | 3202 EXPECT_EQ(views::InkDropState::ACTIVATED, |
| 3135 overflow_button_ink_drop_->GetTargetInkDropState()); | 3203 overflow_button_ink_drop_->GetTargetInkDropState()); |
| 3136 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 3204 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
| 3137 IsEmpty()); | 3205 IsEmpty()); |
| 3138 | 3206 |
| 3139 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 3207 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 3140 } | 3208 } |
| 3141 | 3209 |
| 3142 } // namespace test | 3210 } // namespace test |
| 3143 } // namespace ash | 3211 } // namespace ash |
| OLD | NEW |