| OLD | NEW |
| 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_item_list.h" | 5 #include "ui/app_list/app_list_item_list.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/app_list/app_list_folder_item.h" | 12 #include "ui/app_list/app_list_folder_item.h" |
| 11 #include "ui/app_list/app_list_item.h" | 13 #include "ui/app_list/app_list_item.h" |
| 12 #include "ui/app_list/app_list_item_list_observer.h" | 14 #include "ui/app_list/app_list_item_list_observer.h" |
| 13 | 15 |
| 14 namespace app_list { | 16 namespace app_list { |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 83 |
| 82 scoped_ptr<AppListItem> CreateItem(const std::string& name) { | 84 scoped_ptr<AppListItem> CreateItem(const std::string& name) { |
| 83 scoped_ptr<AppListItem> item(new AppListItem(name)); | 85 scoped_ptr<AppListItem> item(new AppListItem(name)); |
| 84 size_t nitems = item_list_.item_count(); | 86 size_t nitems = item_list_.item_count(); |
| 85 syncer::StringOrdinal position; | 87 syncer::StringOrdinal position; |
| 86 if (nitems == 0) | 88 if (nitems == 0) |
| 87 position = syncer::StringOrdinal::CreateInitialOrdinal(); | 89 position = syncer::StringOrdinal::CreateInitialOrdinal(); |
| 88 else | 90 else |
| 89 position = item_list_.item_at(nitems - 1)->position().CreateAfter(); | 91 position = item_list_.item_at(nitems - 1)->position().CreateAfter(); |
| 90 item->set_position(position); | 92 item->set_position(position); |
| 91 return item.Pass(); | 93 return item; |
| 92 } | 94 } |
| 93 | 95 |
| 94 AppListItem* CreateAndAddItem(const std::string& name) { | 96 AppListItem* CreateAndAddItem(const std::string& name) { |
| 95 scoped_ptr<AppListItem> item(CreateItem(name)); | 97 scoped_ptr<AppListItem> item(CreateItem(name)); |
| 96 return item_list_.AddItem(item.Pass()); | 98 return item_list_.AddItem(std::move(item)); |
| 97 } | 99 } |
| 98 | 100 |
| 99 scoped_ptr<AppListItem> RemoveItem(const std::string& id) { | 101 scoped_ptr<AppListItem> RemoveItem(const std::string& id) { |
| 100 return item_list_.RemoveItem(id); | 102 return item_list_.RemoveItem(id); |
| 101 } | 103 } |
| 102 | 104 |
| 103 scoped_ptr<AppListItem> RemoveItemAt(size_t index) { | 105 scoped_ptr<AppListItem> RemoveItemAt(size_t index) { |
| 104 return item_list_.RemoveItemAt(index); | 106 return item_list_.RemoveItemAt(index); |
| 105 } | 107 } |
| 106 | 108 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 EXPECT_TRUE(VerifyItemListOrdinals()); | 357 EXPECT_TRUE(VerifyItemListOrdinals()); |
| 356 EXPECT_TRUE(VerifyItemOrder4(2, 0, 3, 1)); | 358 EXPECT_TRUE(VerifyItemOrder4(2, 0, 3, 1)); |
| 357 // last -> last | 359 // last -> last |
| 358 item_list_.SetItemPosition(item_list_.item_at(3), | 360 item_list_.SetItemPosition(item_list_.item_at(3), |
| 359 item_list_.item_at(3)->position().CreateAfter()); | 361 item_list_.item_at(3)->position().CreateAfter()); |
| 360 EXPECT_TRUE(VerifyItemListOrdinals()); | 362 EXPECT_TRUE(VerifyItemListOrdinals()); |
| 361 EXPECT_TRUE(VerifyItemOrder4(2, 0, 3, 1)); | 363 EXPECT_TRUE(VerifyItemOrder4(2, 0, 3, 1)); |
| 362 } | 364 } |
| 363 | 365 |
| 364 } // namespace app_list | 366 } // namespace app_list |
| OLD | NEW |