Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm

Issue 12701022: wrongbaseurl OSX App List Pager and root view controller. (Closed) Base URL: http://git.chromium.org/chromium/src.git@20130304-crbug-138633-osx-app-list-demo-polish-macbook
Patch Set: delegate should be owned by viewcontroller, test coverage Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/cocoa/test/apps_grid_controller_test_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm
diff --git a/ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm b/ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm
new file mode 100644
index 0000000000000000000000000000000000000000..4cbc5c0b2e70e197bbd05501bcecb6b1df51c56e
--- /dev/null
+++ b/ui/app_list/cocoa/test/apps_grid_controller_test_helper.mm
@@ -0,0 +1,102 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ui/app_list/cocoa/test/apps_grid_controller_test_helper.h"
+
+#include "base/mac/foundation_util.h"
+#import "ui/app_list/cocoa/apps_grid_controller.h"
+#import "ui/app_list/cocoa/apps_grid_view_item.h"
+#include "ui/app_list/test/app_list_test_model.h"
+#include "ui/app_list/test/app_list_test_view_delegate.h"
+#import "ui/base/test/cocoa_test_event_utils.h"
+
+namespace app_list {
+namespace test {
+
+const size_t AppsGridControllerTestHelper::kItemsPerPage = 16;
+
+AppsGridControllerTestHelper::AppsGridControllerTestHelper() {
+ Init();
+ delegate_.reset(new AppListTestViewDelegate);
+}
+
+AppsGridControllerTestHelper::~AppsGridControllerTestHelper() {}
+
+void AppsGridControllerTestHelper::SetUpWithGridController(
+ AppsGridController* grid_controller) {
+ ui::CocoaTest::SetUp();
+ apps_grid_controller_ = grid_controller;
+ scoped_ptr<AppListModel> model(new AppListTestModel);
+ [apps_grid_controller_ setModel:model.Pass()];
+}
+
+void AppsGridControllerTestHelper::SimulateClick(NSView* view) {
+ std::pair<NSEvent*, NSEvent*> events(
+ cocoa_test_event_utils::MouseClickInView(view, 1));
+ [NSApp postEvent:events.first atStart:NO];
+ [NSApp postEvent:events.second atStart:NO];
+}
+
+void AppsGridControllerTestHelper::SimulateKeyPress(unichar c) {
+ [test_window() keyDown:cocoa_test_event_utils::KeyEventWithCharacter(c)];
+}
+
+void AppsGridControllerTestHelper::SimulateMouseEnterItemAt(size_t index) {
+ [[apps_grid_controller_ itemAtIndex:index] mouseEntered:
+ cocoa_test_event_utils::EnterExitEventWithType(NSMouseEntered)];
+}
+
+void AppsGridControllerTestHelper::SimulateMouseExitItemAt(size_t index) {
+ [[apps_grid_controller_ itemAtIndex:index] mouseExited:
+ cocoa_test_event_utils::EnterExitEventWithType(NSMouseExited)];
+}
+
+void AppsGridControllerTestHelper::ReplaceTestModel(int item_count) {
+ scoped_ptr<AppListTestModel> new_model(new AppListTestModel);
+ new_model->PopulateApps(item_count);
+ [apps_grid_controller_ setModel:new_model.PassAs<AppListModel>()];
+}
+
+void AppsGridControllerTestHelper::DelayForCollectionView() {
+ message_loop_.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),
+ base::TimeDelta::FromMilliseconds(100));
+ message_loop_.Run();
+}
+
+void AppsGridControllerTestHelper::SinkEvents() {
+ message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
+ message_loop_.Run();
+}
+
+NSButton* AppsGridControllerTestHelper::GetItemViewAt(size_t index) {
+ return [[apps_grid_controller_ itemAtIndex:index] button];
+}
+
+NSCollectionView* AppsGridControllerTestHelper::GetPageAt(size_t index) {
+ return [apps_grid_controller_ collectionViewAtPageIndex:index];
+}
+
+NSView* AppsGridControllerTestHelper::GetSelectedView() {
+ // TODO(tapted): Update this to work for selections on other than the first
+ // page.
+ NSIndexSet* selection = [GetPageAt(0) selectionIndexes];
+ if ([selection count]) {
+ AppsGridViewItem* item = base::mac::ObjCCastStrict<AppsGridViewItem>(
+ [GetPageAt(0) itemAtIndex:[selection firstIndex]]);
+ return [item button];
+ }
+
+ return nil;
+}
+
+AppListTestViewDelegate* AppsGridControllerTestHelper::delegate() {
+ return static_cast<AppListTestViewDelegate*>(delegate_.get());
+}
+
+AppListTestModel* AppsGridControllerTestHelper::model() {
+ return static_cast<AppListTestModel*>([apps_grid_controller_ model]);
+}
+
+} // namespace test
+} // namespace app_list
« no previous file with comments | « ui/app_list/cocoa/test/apps_grid_controller_test_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698