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

Side by Side Diff: ui/app_list/test/app_list_test_model.h

Issue 27438002: Store AppItems as pages in AppListModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 2 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 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 #ifndef UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_ 5 #ifndef UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_
6 #define UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_ 6 #define UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
11 11
12 namespace app_list { 12 namespace app_list {
13 13
14 class AppListItemModel; 14 class AppListItemModel;
15 15
16 namespace test { 16 namespace test {
17 17
18 // Extends AppListModel with helper functions for use in tests. 18 // Extends AppListModel with helper functions for use in tests.
19 class AppListTestModel : public AppListModel { 19 class AppListTestModel : public AppListModel {
20 public: 20 public:
21 AppListTestModel(); 21 AppListTestModel();
22 22
23 // Generates a name based on |id|.
24 std::string GetItemName(int id);
25
23 // Populate the model with |n| items titled "Item #". 26 // Populate the model with |n| items titled "Item #".
24 void PopulateApps(int n); 27 void PopulateApps(int n);
25 28
26 // Populate the model with an item titled "Item |id|". 29 // Populate the model with an item titled "Item |id|".
27 void PopulateAppWithId(int id); 30 void PopulateAppWithId(int id);
28 31
29 // Get a string of all apps in |model| joined with ','. 32 // Get a string of all apps in |model| joined with ','.
30 std::string GetModelContent(); 33 std::string GetModelContent();
31 34
35 // Creates an item with |title| and |full_name|.
32 AppListItemModel* CreateItem(const std::string& title, 36 AppListItemModel* CreateItem(const std::string& title,
33 const std::string& full_name); 37 const std::string& full_name);
34 38
35 // Add an item with arbitrary |title| and |full_name| to the model. 39 // Creates and adds an item with |title| and |full_name| to the model.
36 void AddItem(const std::string& title, const std::string& full_name); 40 void CreateAndAddItem(const std::string& title, const std::string& full_name);
37 41
38 // Add an item with arbitrary |title| to the model. This is a convenience 42 // Convenience version of CreateAndAddItem(title, title).
39 // version which will use the title for the full_name. 43 void CreateAndAddItem(const std::string& title);
40 void AddItem(const std::string& title);
41 44
42 // Call SetHighlighted on the specified item. 45 // Call SetHighlighted on the specified item.
43 void HighlightItemAt(int index); 46 void HighlightItemAt(int index);
44 47
45 int activate_count() { return activate_count_; } 48 int activate_count() { return activate_count_; }
46 AppListItemModel* last_activated() { return last_activated_; } 49 AppListItemModel* last_activated() { return last_activated_; }
47 50
48 private: 51 private:
49 class AppListTestItemModel; 52 class AppListTestItemModel;
50 53
51 void ItemActivated(AppListTestItemModel* item); 54 void ItemActivated(AppListTestItemModel* item);
52 55
53 int activate_count_; 56 int activate_count_;
54 AppListItemModel* last_activated_; 57 AppListItemModel* last_activated_;
55 58
56 DISALLOW_COPY_AND_ASSIGN(AppListTestModel); 59 DISALLOW_COPY_AND_ASSIGN(AppListTestModel);
57 }; 60 };
58 61
59 } // namespace test 62 } // namespace test
60 } // namespace app_list 63 } // namespace app_list
61 64
62 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_ 65 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698