| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "base/memory/scoped_nsobject.h" | 5 #import "base/memory/scoped_nsobject.h" |
| 6 #import "testing/gtest_mac.h" | 6 #import "testing/gtest_mac.h" |
| 7 #include "ui/app_list/app_list_view_delegate.h" | 7 #include "ui/app_list/app_list_view_delegate.h" |
| 8 #import "ui/app_list/cocoa/apps_grid_controller.h" | 8 #import "ui/app_list/cocoa/app_list_view_controller.h" |
| 9 #import "ui/app_list/cocoa/app_list_window_controller.h" | 9 #import "ui/app_list/cocoa/app_list_window_controller.h" |
| 10 #include "ui/app_list/test/app_list_test_view_delegate.h" | 10 #include "ui/app_list/test/app_list_test_view_delegate.h" |
| 11 #import "ui/base/test/ui_cocoa_test_helper.h" | 11 #import "ui/base/test/ui_cocoa_test_helper.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class AppListWindowControllerTest : public ui::CocoaTest { | 15 class AppListWindowControllerTest : public ui::CocoaTest { |
| 16 public: | 16 public: |
| 17 AppListWindowControllerTest(); | 17 AppListWindowControllerTest(); |
| 18 | 18 |
| 19 protected: | 19 protected: |
| 20 virtual void TearDown() OVERRIDE; | 20 virtual void TearDown() OVERRIDE; |
| 21 | 21 |
| 22 scoped_nsobject<AppListWindowController> controller_; | 22 scoped_nsobject<AppListWindowController> controller_; |
| 23 | 23 |
| 24 app_list::test::AppListTestViewDelegate* delegate() { | 24 app_list::test::AppListTestViewDelegate* delegate() { |
| 25 return static_cast<app_list::test::AppListTestViewDelegate*>( | 25 return static_cast<app_list::test::AppListTestViewDelegate*>( |
| 26 [[controller_ appsGridController] delegate]); | 26 [[controller_ appListViewController] delegate]); |
| 27 } | 27 } |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(AppListWindowControllerTest); | 30 DISALLOW_COPY_AND_ASSIGN(AppListWindowControllerTest); |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 AppListWindowControllerTest::AppListWindowControllerTest() { | 33 AppListWindowControllerTest::AppListWindowControllerTest() { |
| 34 Init(); | 34 Init(); |
| 35 scoped_ptr<app_list::AppListViewDelegate> delegate( | 35 scoped_ptr<app_list::AppListViewDelegate> delegate( |
| 36 new app_list::test::AppListTestViewDelegate); | 36 new app_list::test::AppListTestViewDelegate); |
| 37 scoped_nsobject<AppsGridController> content( | 37 controller_.reset([[AppListWindowController alloc] init]); |
| 38 [[AppsGridController alloc] initWithViewDelegate:delegate.Pass()]); | 38 [[controller_ appListViewController] setDelegate:delegate.Pass()]; |
| 39 controller_.reset( | |
| 40 [[AppListWindowController alloc] initWithGridController:content]); | |
| 41 } | 39 } |
| 42 | 40 |
| 43 void AppListWindowControllerTest::TearDown() { | 41 void AppListWindowControllerTest::TearDown() { |
| 44 EXPECT_TRUE(controller_.get()); | 42 EXPECT_TRUE(controller_.get()); |
| 45 [[controller_ window] close]; | 43 [[controller_ window] close]; |
| 46 controller_.reset(); | 44 controller_.reset(); |
| 47 ui::CocoaTest::TearDown(); | 45 ui::CocoaTest::TearDown(); |
| 48 } | 46 } |
| 49 | 47 |
| 50 } // namespace | 48 } // namespace |
| (...skipping 10 matching lines...) Expand all Loading... |
| 61 } | 59 } |
| 62 | 60 |
| 63 // Test that the key bound to cancel (usually Escape) asks the controller to | 61 // Test that the key bound to cancel (usually Escape) asks the controller to |
| 64 // dismiss the window. | 62 // dismiss the window. |
| 65 TEST_F(AppListWindowControllerTest, DismissWithEscape) { | 63 TEST_F(AppListWindowControllerTest, DismissWithEscape) { |
| 66 [[controller_ window] makeKeyAndOrderFront:nil]; | 64 [[controller_ window] makeKeyAndOrderFront:nil]; |
| 67 EXPECT_EQ(0, delegate()->dismiss_count()); | 65 EXPECT_EQ(0, delegate()->dismiss_count()); |
| 68 [[controller_ window] cancelOperation:controller_]; | 66 [[controller_ window] cancelOperation:controller_]; |
| 69 EXPECT_EQ(1, delegate()->dismiss_count()); | 67 EXPECT_EQ(1, delegate()->dismiss_count()); |
| 70 } | 68 } |
| OLD | NEW |