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, and not before. | |
koz (OOO until 15th September)
2013/12/02 22:49:45
Maybe elaborate here like "Test that search result
tapted
2013/12/03 01:45:26
Done.
| |
75 TEST_F(AppListWindowControllerTest, CloseClearsSearch) { | |
76 [[controller_ window] makeKeyAndOrderFront:nil]; | |
77 app_list::SearchBoxModel* model = delegate()->GetModel()->search_box(); | |
78 AppListViewController* view_controller = [controller_ appListViewController]; | |
79 | |
80 EXPECT_FALSE([view_controller showingSearchResults]); | |
81 | |
82 const base::string16 search_text(ASCIIToUTF16("test")); | |
83 model->SetText(search_text); | |
84 EXPECT_TRUE([view_controller showingSearchResults]); | |
85 | |
86 EXPECT_EQ(0, delegate()->open_search_result_count()); | |
87 [view_controller openResult:nil]; | |
88 EXPECT_EQ(1, delegate()->open_search_result_count()); | |
89 | |
90 EXPECT_TRUE([view_controller showingSearchResults]); | |
91 [[controller_ window] close]; // Hide. | |
92 EXPECT_FALSE([view_controller showingSearchResults]); | |
93 } | |
OLD | NEW |