apps_grid_controller_test_helper.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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 { 15namespace test { 16 17class AppListTestViewDelegate; 18class AppListTestModel; 19 20class 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 press to the first responder. 34 void SimulateKeyPress(unichar c); 35 36 void SimulateMouseEnterItemAt(size_t index); 37 void SimulateMouseExitItemAt(size_t index); 38 39 // Do a bulk replacement of the items in the grid. 40 void ReplaceTestModel(int item_count); 41 42 // Get a string representation of the items as they are currently ordered in 43 // the view. Each page will start and end with a | character. 44 std::string GetViewContent() const; 45 46 // Find the page containing |item_id|, and return the index of that page. 47 // Return NSNotFound if the item is not found, or if the item appears more 48 // than once. 49 size_t GetPageIndexForItem(int item_id) const; 50 51 void DelayForCollectionView(); 52 void SinkEvents(); 53 54 NSButton* GetItemViewAt(size_t index); 55 NSCollectionView* GetPageAt(size_t index); 56 NSView* GetSelectedView(); 57 58 AppListTestViewDelegate* delegate(); 59 AppListTestModel* model(); 60 61 scoped_ptr<AppListTestViewDelegate> delegate_; 62 AppsGridController* apps_grid_controller_; 63 64 private: 65 base::MessageLoopForUI message_loop_; 66 67 DISALLOW_COPY_AND_ASSIGN(AppsGridControllerTestHelper); 68}; 69 70} // namespace test 71} // namespace app_list 72 73#endif // UI_APP_LIST_COCOA_TEST_APPS_GRID_CONTROLLER_TEST_HELPER_H_ 74