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

Side by Side Diff: ui/app_list/app_list_model_unittest.cc

Issue 305013014: Disable folder UI when app sync is disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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
« no previous file with comments | « ui/app_list/app_list_model.cc ('k') | ui/app_list/test/app_list_test_view_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list_model.h" 5 #include "ui/app_list/app_list_model.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Ensure order is preserved. 224 // Ensure order is preserved.
225 for (size_t i = 1; i < num_apps; ++i) { 225 for (size_t i = 1; i < num_apps; ++i) {
226 EXPECT_TRUE( 226 EXPECT_TRUE(
227 model_.top_level_item_list()->item_at(i)->position().GreaterThan( 227 model_.top_level_item_list()->item_at(i)->position().GreaterThan(
228 model_.top_level_item_list()->item_at(i - 1)->position())); 228 model_.top_level_item_list()->item_at(i - 1)->position()));
229 } 229 }
230 } 230 }
231 231
232 class AppListModelFolderTest : public AppListModelTest { 232 class AppListModelFolderTest : public AppListModelTest {
233 public: 233 public:
234 AppListModelFolderTest() {} 234 AppListModelFolderTest() {
235 model_.SetFoldersEnabled(true);
236 }
235 virtual ~AppListModelFolderTest() {} 237 virtual ~AppListModelFolderTest() {}
236 238
237 // testing::Test overrides: 239 // testing::Test overrides:
238 virtual void SetUp() OVERRIDE { 240 virtual void SetUp() OVERRIDE {
239 AppListModelTest::SetUp(); 241 AppListModelTest::SetUp();
240 } 242 }
241 virtual void TearDown() OVERRIDE { 243 virtual void TearDown() OVERRIDE {
242 AppListModelTest::TearDown(); 244 AppListModelTest::TearDown();
243 } 245 }
244 246
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 461
460 // Should not be able to move from an OEM folder with MoveItemToFolderAt. 462 // Should not be able to move from an OEM folder with MoveItemToFolderAt.
461 AppListItem* item1 = new AppListItem("Item 1"); 463 AppListItem* item1 = new AppListItem("Item 1");
462 model_.AddItemToFolder(item1, folder_id); 464 model_.AddItemToFolder(item1, folder_id);
463 syncer::StringOrdinal item1_pos = item1->position(); 465 syncer::StringOrdinal item1_pos = item1->position();
464 bool move_res = model_.MoveItemToFolderAt(item1, "", syncer::StringOrdinal()); 466 bool move_res = model_.MoveItemToFolderAt(item1, "", syncer::StringOrdinal());
465 EXPECT_FALSE(move_res); 467 EXPECT_FALSE(move_res);
466 EXPECT_TRUE(item1->position().Equals(item1_pos)); 468 EXPECT_TRUE(item1->position().Equals(item1_pos));
467 } 469 }
468 470
471 TEST_F(AppListModelFolderTest, DisableFolders) {
472 // Set up a folder with two items and an OEM folder with one item.
473 AppListFolderItem* folder =
474 new AppListFolderItem("folder1", AppListFolderItem::FOLDER_TYPE_NORMAL);
475 model_.AddItem(folder);
476 std::string folder_id = folder->id();
477 AppListItem* item0 = new AppListItem("Item 0");
478 model_.AddItemToFolder(item0, folder_id);
479 AppListItem* item1 = new AppListItem("Item 1");
480 model_.AddItemToFolder(item1, folder_id);
481 AppListFolderItem* folder_item = model_.FindFolderItem(folder_id);
482 ASSERT_TRUE(folder_item);
483 EXPECT_EQ(2u, folder_item->item_list()->item_count());
484 AppListFolderItem* oem_folder =
485 new AppListFolderItem("oem_folder", AppListFolderItem::FOLDER_TYPE_OEM);
486 model_.AddItem(oem_folder);
487 AppListItem* oem_item = new AppListItem("OEM Item");
488 std::string oem_folder_id = oem_folder->id();
489 model_.AddItemToFolder(oem_item, oem_folder_id);
490 EXPECT_EQ("folder1,oem_folder", GetModelContents());
491
492 // Disable folders. Ensure non-oem folder is removed.
493 model_.SetFoldersEnabled(false);
494 ASSERT_FALSE(model_.FindFolderItem(folder_id));
495 ASSERT_TRUE(model_.FindFolderItem(oem_folder_id));
496 EXPECT_EQ("Item 0,Item 1,oem_folder", GetModelContents());
497
498 // Ensure folder creation fails.
499 EXPECT_EQ(std::string(), model_.MergeItems(item0->id(), item1->id()));
500 }
501
469 } // namespace app_list 502 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/app_list_model.cc ('k') | ui/app_list/test/app_list_test_view_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698