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