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

Side by Side Diff: ui/app_list/views/apps_grid_view_unittest.cc

Issue 148403007: Protect AppListItemList Add/Remove and fix sync bugs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 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/app_list/views/apps_grid_view.h" 5 #include "ui/app_list/views/apps_grid_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 TEST_F(AppsGridViewTest, RemoveSelectedLastApp) { 213 TEST_F(AppsGridViewTest, RemoveSelectedLastApp) {
214 const int kTotalItems = 2; 214 const int kTotalItems = 2;
215 const int kLastItemIndex = kTotalItems - 1; 215 const int kLastItemIndex = kTotalItems - 1;
216 216
217 model_->PopulateApps(kTotalItems); 217 model_->PopulateApps(kTotalItems);
218 218
219 AppListItemView* last_view = GetItemViewAt(kLastItemIndex); 219 AppListItemView* last_view = GetItemViewAt(kLastItemIndex);
220 apps_grid_view_->SetSelectedView(last_view); 220 apps_grid_view_->SetSelectedView(last_view);
221 model_->item_list()->DeleteItem(model_->GetItemName(kLastItemIndex)); 221 model_->DeleteItem(model_->GetItemName(kLastItemIndex));
222 222
223 EXPECT_FALSE(apps_grid_view_->IsSelectedView(last_view)); 223 EXPECT_FALSE(apps_grid_view_->IsSelectedView(last_view));
224 224
225 // No crash happens. 225 // No crash happens.
226 AppListItemView* view = GetItemViewAt(0); 226 AppListItemView* view = GetItemViewAt(0);
227 apps_grid_view_->SetSelectedView(view); 227 apps_grid_view_->SetSelectedView(view);
228 EXPECT_TRUE(apps_grid_view_->IsSelectedView(view)); 228 EXPECT_TRUE(apps_grid_view_->IsSelectedView(view));
229 } 229 }
230 230
231 TEST_F(AppsGridViewTest, MouseDrag) { 231 TEST_F(AppsGridViewTest, MouseDrag) {
(...skipping 14 matching lines...) Expand all
246 246
247 // Canceling drag should keep existing order. 247 // Canceling drag should keep existing order.
248 SimulateDrag(AppsGridView::MOUSE, from, to); 248 SimulateDrag(AppsGridView::MOUSE, from, to);
249 apps_grid_view_->EndDrag(true); 249 apps_grid_view_->EndDrag(true);
250 EXPECT_EQ(std::string("Item 1,Item 0,Item 2,Item 3"), 250 EXPECT_EQ(std::string("Item 1,Item 0,Item 2,Item 3"),
251 model_->GetModelContent()); 251 model_->GetModelContent());
252 test_api_->LayoutToIdealBounds(); 252 test_api_->LayoutToIdealBounds();
253 253
254 // Deleting an item keeps remaining intact. 254 // Deleting an item keeps remaining intact.
255 SimulateDrag(AppsGridView::MOUSE, from, to); 255 SimulateDrag(AppsGridView::MOUSE, from, to);
256 model_->item_list()->DeleteItem(model_->GetItemName(0)); 256 model_->DeleteItem(model_->GetItemName(0));
257 apps_grid_view_->EndDrag(false); 257 apps_grid_view_->EndDrag(false);
258 EXPECT_EQ(std::string("Item 1,Item 2,Item 3"), 258 EXPECT_EQ(std::string("Item 1,Item 2,Item 3"),
259 model_->GetModelContent()); 259 model_->GetModelContent());
260 test_api_->LayoutToIdealBounds(); 260 test_api_->LayoutToIdealBounds();
261 261
262 // Adding a launcher item cancels the drag and respects the order. 262 // Adding a launcher item cancels the drag and respects the order.
263 SimulateDrag(AppsGridView::MOUSE, from, to); 263 SimulateDrag(AppsGridView::MOUSE, from, to);
264 model_->CreateAndAddItem("Extra"); 264 model_->CreateAndAddItem("Extra");
265 apps_grid_view_->EndDrag(false); 265 apps_grid_view_->EndDrag(false);
266 EXPECT_EQ(std::string("Item 1,Item 2,Item 3,Extra"), 266 EXPECT_EQ(std::string("Item 1,Item 2,Item 3,Extra"),
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 AppListItemView* item_view = GetItemViewAt(0); 455 AppListItemView* item_view = GetItemViewAt(0);
456 ASSERT_TRUE(item_view); 456 ASSERT_TRUE(item_view);
457 const views::Label* title_label = item_view->title(); 457 const views::Label* title_label = item_view->title();
458 EXPECT_FALSE(title_label->GetTooltipText( 458 EXPECT_FALSE(title_label->GetTooltipText(
459 title_label->bounds().CenterPoint(), &actual_tooltip)); 459 title_label->bounds().CenterPoint(), &actual_tooltip));
460 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); 460 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text()));
461 } 461 }
462 462
463 } // namespace test 463 } // namespace test
464 } // namespace app_list 464 } // namespace app_list
OLDNEW
« ui/app_list/views/apps_grid_view.cc ('K') | « ui/app_list/views/apps_grid_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698