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 #import "testing/gtest_mac.h" | 7 #import "testing/gtest_mac.h" |
7 #include "ui/app_list/app_list_view_delegate.h" | 8 #include "ui/app_list/app_list_view_delegate.h" |
8 #import "ui/app_list/cocoa/app_list_view_controller.h" | 9 #import "ui/app_list/cocoa/app_list_view_controller.h" |
9 #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" |
10 #include "ui/app_list/test/app_list_test_view_delegate.h" | 12 #include "ui/app_list/test/app_list_test_view_delegate.h" |
11 #import "ui/base/test/ui_cocoa_test_helper.h" | 13 #import "ui/base/test/ui_cocoa_test_helper.h" |
12 | 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 class AppListWindowControllerTest : public ui::CocoaTest { | 17 class AppListWindowControllerTest : public ui::CocoaTest { |
16 public: | 18 public: |
17 AppListWindowControllerTest(); | 19 AppListWindowControllerTest(); |
18 | 20 |
19 protected: | 21 protected: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 63 } |
62 | 64 |
63 // Test that the key bound to cancel (usually Escape) asks the controller to | 65 // Test that the key bound to cancel (usually Escape) asks the controller to |
64 // dismiss the window. | 66 // dismiss the window. |
65 TEST_F(AppListWindowControllerTest, DismissWithEscape) { | 67 TEST_F(AppListWindowControllerTest, DismissWithEscape) { |
66 [[controller_ window] makeKeyAndOrderFront:nil]; | 68 [[controller_ window] makeKeyAndOrderFront:nil]; |
67 EXPECT_EQ(0, delegate()->dismiss_count()); | 69 EXPECT_EQ(0, delegate()->dismiss_count()); |
68 [[controller_ window] cancelOperation:controller_]; | 70 [[controller_ window] cancelOperation:controller_]; |
69 EXPECT_EQ(1, delegate()->dismiss_count()); | 71 EXPECT_EQ(1, delegate()->dismiss_count()); |
70 } | 72 } |
| 73 |
| 74 // Test that search results are cleared when the window closes, not when a |
| 75 // search result is selected. If cleared upon selection, the animation showing |
| 76 // the results sliding away is seen as the window closes, which looks weird. |
| 77 TEST_F(AppListWindowControllerTest, CloseClearsSearch) { |
| 78 [[controller_ window] makeKeyAndOrderFront:nil]; |
| 79 app_list::SearchBoxModel* model = delegate()->GetModel()->search_box(); |
| 80 AppListViewController* view_controller = [controller_ appListViewController]; |
| 81 |
| 82 EXPECT_FALSE([view_controller showingSearchResults]); |
| 83 |
| 84 const base::string16 search_text(ASCIIToUTF16("test")); |
| 85 model->SetText(search_text); |
| 86 EXPECT_TRUE([view_controller showingSearchResults]); |
| 87 |
| 88 EXPECT_EQ(0, delegate()->open_search_result_count()); |
| 89 [view_controller openResult:nil]; |
| 90 EXPECT_EQ(1, delegate()->open_search_result_count()); |
| 91 |
| 92 EXPECT_TRUE([view_controller showingSearchResults]); |
| 93 [[controller_ window] close]; // Hide. |
| 94 EXPECT_FALSE([view_controller showingSearchResults]); |
| 95 } |
OLD | NEW |