Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / test / app_list_test_model.h
blob43a79ab34ea577d1b2e0af8ae80a267a579a712a
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_
6 #define UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_
8 #include <string>
10 #include "ui/app_list/app_list_folder_item.h"
11 #include "ui/app_list/app_list_item.h"
12 #include "ui/app_list/app_list_model.h"
14 namespace app_list {
16 namespace test {
18 // Extends AppListModel with helper functions for use in tests.
19 class AppListTestModel : public AppListModel {
20 public:
21 class AppListTestItem : public AppListItem {
22 public:
23 AppListTestItem(const std::string& id, AppListTestModel* model);
24 ~AppListTestItem() override;
25 void Activate(int event_flags) override;
26 const char* GetItemType() const override;
28 void SetPosition(const syncer::StringOrdinal& new_position);
30 private:
31 AppListTestModel* model_;
33 DISALLOW_COPY_AND_ASSIGN(AppListTestItem);
36 static const char kItemType[];
38 AppListTestModel();
40 // Raw pointer version convenience versions of AppListModel methods.
41 AppListItem* AddItem(AppListItem* item);
42 AppListItem* AddItemToFolder(AppListItem* item, const std::string& folder_id);
43 void MoveItemToFolder(AppListItem* item, const std::string& folder_id);
45 // Generates a name based on |id|.
46 std::string GetItemName(int id);
48 // Populate the model with |n| items titled "Item #".
49 void PopulateApps(int n);
51 // Creates and populate a folder with |n| test apps in it.
52 AppListFolderItem* CreateAndPopulateFolderWithApps(int n);
54 AppListFolderItem* CreateAndAddOemFolder(const std::string& id);
56 AppListFolderItem* CreateSingleItemFolder(const std::string& folder_id,
57 const std::string& item_id);
59 // Populate the model with an item titled "Item |id|".
60 void PopulateAppWithId(int id);
62 // Get a string of all apps in |model| joined with ','.
63 std::string GetModelContent();
65 // Creates an item with id |id|. Caller owns the result.
66 AppListTestItem* CreateItem(const std::string& id);
68 // Creates and adds an item with id |id| to the model. Returns an unowned
69 // pointer to the created item.
70 AppListTestItem* CreateAndAddItem(const std::string& id);
72 // Call SetHighlighted on the specified item.
73 void HighlightItemAt(int index);
75 int activate_count() { return activate_count_; }
76 AppListItem* last_activated() { return last_activated_; }
78 private:
79 void ItemActivated(AppListTestItem* item);
81 int activate_count_;
82 AppListItem* last_activated_;
84 DISALLOW_COPY_AND_ASSIGN(AppListTestModel);
87 } // namespace test
88 } // namespace app_list
90 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_