apps_grid_controller_test_helper.h revision 868fa2fe829687343ffae624259930155e16dbd8
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.
4
5#ifndef UI_APP_LIST_COCOA_TEST_APPS_GRID_CONTROLLER_TEST_HELPER_H_
6#define UI_APP_LIST_COCOA_TEST_APPS_GRID_CONTROLLER_TEST_HELPER_H_
7
8#include "base/memory/scoped_ptr.h"
9#include "base/message_loop.h"
10#import "ui/base/test/ui_cocoa_test_helper.h"
11
12@class AppsGridController;
13
14namespace app_list {
15
16class AppListModel;
17
18namespace test {
19
20class AppListTestViewDelegate;
21class AppListTestModel;
22
23class AppsGridControllerTestHelper : public ui::CocoaTest {
24 public:
25  static const size_t kItemsPerPage;
26
27  AppsGridControllerTestHelper();
28  virtual ~AppsGridControllerTestHelper();
29
30  void SetUpWithGridController(AppsGridController* grid_controller);
31
32 protected:
33  // Send a click to the test window in the centre of |view|.
34  void SimulateClick(NSView* view);
35
36  // Send a key action using handleCommandBySelector.
37  void SimulateKeyAction(SEL c);
38
39  void SimulateMouseEnterItemAt(size_t index);
40  void SimulateMouseExitItemAt(size_t index);
41
42  // Do a bulk replacement of the items in the grid.
43  void ReplaceTestModel(int item_count);
44
45  // Get a string representation of the items as they are currently ordered in
46  // the view. Each page will start and end with a | character.
47  std::string GetViewContent() const;
48
49  // Find the page containing |item_id|, and return the index of that page.
50  // Return NSNotFound if the item is not found, or if the item appears more
51  // than once.
52  size_t GetPageIndexForItem(int item_id) const;
53
54  void DelayForCollectionView();
55  void SinkEvents();
56
57  NSButton* GetItemViewAt(size_t index);
58  NSCollectionView* GetPageAt(size_t index);
59  NSView* GetSelectedView();
60
61  AppListTestModel* model();
62
63  virtual void ResetModel(scoped_ptr<AppListModel> model);
64
65  AppsGridController* apps_grid_controller_;
66
67 private:
68  base::MessageLoopForUI message_loop_;
69
70  DISALLOW_COPY_AND_ASSIGN(AppsGridControllerTestHelper);
71};
72
73}  // namespace test
74}  // namespace app_list
75
76#endif  // UI_APP_LIST_COCOA_TEST_APPS_GRID_CONTROLLER_TEST_HELPER_H_
77