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_
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"
18 // Extends AppListModel with helper functions for use in tests.
19 class AppListTestModel
: public AppListModel
{
21 class AppListTestItem
: public AppListItem
{
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
);
31 AppListTestModel
* model_
;
33 DISALLOW_COPY_AND_ASSIGN(AppListTestItem
);
36 static const char kItemType
[];
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_
; }
79 void ItemActivated(AppListTestItem
* item
);
82 AppListItem
* last_activated_
;
84 DISALLOW_COPY_AND_ASSIGN(AppListTestModel
);
88 } // namespace app_list
90 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_MODEL_H_