| 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/mac/scoped_nsobject.h" | 5 #import "base/mac/scoped_nsobject.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #import "testing/gtest_mac.h" | 7 #import "testing/gtest_mac.h" |
| 8 #include "ui/app_list/app_list_view_delegate.h" | 8 #include "ui/app_list/app_list_view_delegate.h" |
| 9 #import "ui/app_list/cocoa/app_list_view_controller.h" | 9 #import "ui/app_list/cocoa/app_list_view_controller.h" |
| 10 #import "ui/app_list/cocoa/app_list_window_controller.h" | 10 #import "ui/app_list/cocoa/app_list_window_controller.h" |
| 11 #include "ui/app_list/search_box_model.h" | 11 #include "ui/app_list/search_box_model.h" |
| 12 #include "ui/app_list/test/app_list_test_view_delegate.h" | 12 #include "ui/app_list/test/app_list_test_view_delegate.h" |
| 13 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 13 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class AppListWindowControllerTest : public ui::CocoaTest { | 17 class AppListWindowControllerTest : public ui::CocoaTest { |
| 18 public: | 18 public: |
| 19 AppListWindowControllerTest(); | 19 AppListWindowControllerTest(); |
| 20 | 20 |
| 21 protected: | 21 protected: |
| 22 virtual void TearDown() OVERRIDE; | 22 virtual void TearDown() OVERRIDE; |
| 23 | 23 |
| 24 base::scoped_nsobject<AppListWindowController> controller_; | 24 base::scoped_nsobject<AppListWindowController> controller_; |
| 25 | 25 |
| 26 app_list::test::AppListTestViewDelegate* delegate() { | 26 app_list::test::AppListTestViewDelegate* delegate() { |
| 27 return static_cast<app_list::test::AppListTestViewDelegate*>( | 27 return delegate_.get(); |
| 28 [[controller_ appListViewController] delegate]); | |
| 29 } | 28 } |
| 30 | 29 |
| 31 private: | 30 private: |
| 31 scoped_ptr<app_list::test::AppListTestViewDelegate> delegate_; |
| 32 |
| 32 DISALLOW_COPY_AND_ASSIGN(AppListWindowControllerTest); | 33 DISALLOW_COPY_AND_ASSIGN(AppListWindowControllerTest); |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 AppListWindowControllerTest::AppListWindowControllerTest() { | 36 AppListWindowControllerTest::AppListWindowControllerTest() |
| 37 : delegate_(new app_list::test::AppListTestViewDelegate) { |
| 36 Init(); | 38 Init(); |
| 37 scoped_ptr<app_list::AppListViewDelegate> delegate( | |
| 38 new app_list::test::AppListTestViewDelegate); | |
| 39 controller_.reset([[AppListWindowController alloc] init]); | 39 controller_.reset([[AppListWindowController alloc] init]); |
| 40 [[controller_ appListViewController] setDelegate:delegate.Pass()]; | 40 [[controller_ appListViewController] setDelegate:delegate()]; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void AppListWindowControllerTest::TearDown() { | 43 void AppListWindowControllerTest::TearDown() { |
| 44 EXPECT_TRUE(controller_.get()); | 44 EXPECT_TRUE(controller_.get()); |
| 45 [[controller_ window] close]; | 45 [[controller_ window] close]; |
| 46 [[controller_ appListViewController] | 46 [[controller_ appListViewController] setDelegate:NULL]; |
| 47 setDelegate:scoped_ptr<app_list::AppListViewDelegate>()]; | |
| 48 controller_.reset(); | 47 controller_.reset(); |
| 49 ui::CocoaTest::TearDown(); | 48 ui::CocoaTest::TearDown(); |
| 50 } | 49 } |
| 51 | 50 |
| 52 } // namespace | 51 } // namespace |
| 53 | 52 |
| 54 // Test showing, hiding and closing the app list window. | 53 // Test showing, hiding and closing the app list window. |
| 55 TEST_F(AppListWindowControllerTest, ShowHideCloseRelease) { | 54 TEST_F(AppListWindowControllerTest, ShowHideCloseRelease) { |
| 56 EXPECT_TRUE([controller_ window]); | 55 EXPECT_TRUE([controller_ window]); |
| 57 [[controller_ window] makeKeyAndOrderFront:nil]; | 56 [[controller_ window] makeKeyAndOrderFront:nil]; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 86 EXPECT_TRUE([view_controller showingSearchResults]); | 85 EXPECT_TRUE([view_controller showingSearchResults]); |
| 87 | 86 |
| 88 EXPECT_EQ(0, delegate()->open_search_result_count()); | 87 EXPECT_EQ(0, delegate()->open_search_result_count()); |
| 89 [view_controller openResult:nil]; | 88 [view_controller openResult:nil]; |
| 90 EXPECT_EQ(1, delegate()->open_search_result_count()); | 89 EXPECT_EQ(1, delegate()->open_search_result_count()); |
| 91 | 90 |
| 92 EXPECT_TRUE([view_controller showingSearchResults]); | 91 EXPECT_TRUE([view_controller showingSearchResults]); |
| 93 [[controller_ window] close]; // Hide. | 92 [[controller_ window] close]; // Hide. |
| 94 EXPECT_FALSE([view_controller showingSearchResults]); | 93 EXPECT_FALSE([view_controller showingSearchResults]); |
| 95 } | 94 } |
| OLD | NEW |