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 "ui/app_list/cocoa/apps_search_results_controller.h" | 5 #import "ui/app_list/cocoa/apps_search_results_controller.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #import "testing/gtest_mac.h" | 12 #import "testing/gtest_mac.h" |
13 #include "ui/app_list/search_result.h" | 13 #include "ui/app_list/search_result.h" |
14 #include "ui/app_list/test/app_list_test_model.h" | 14 #include "ui/app_list/test/app_list_test_model.h" |
15 #include "ui/base/models/simple_menu_model.h" | 15 #include "ui/base/models/simple_menu_model.h" |
16 #import "ui/base/test/ui_cocoa_test_helper.h" | 16 #import "ui/base/test/ui_cocoa_test_helper.h" |
17 #include "ui/gfx/image/image_skia_util_mac.h" | 17 #include "ui/gfx/image/image_skia_util_mac.h" |
18 #import "ui/base/test/cocoa_test_event_utils.h" | 18 #import "ui/base/test/cocoa_test_event_utils.h" |
19 | 19 |
20 @interface TestAppsSearchResultsDelegate : NSObject<AppsSearchResultsDelegate> { | 20 @interface TestAppsSearchResultsDelegate : NSObject<AppsSearchResultsDelegate> { |
21 @private | 21 @private |
22 app_list::test::AppListTestModel appListModel_; | 22 app_list::test::AppListTestModel appListModel_; |
23 app_list::SearchResult* lastOpenedResult_; | 23 app_list::SearchResult* lastOpenedResult_; |
24 int redoSearchCount_; | 24 int redoSearchCount_; |
| 25 app_list::SearchResult* resultForLastInvokedAction_; |
| 26 int lastInvokedActinIndex_; |
25 } | 27 } |
26 | 28 |
27 @property(readonly, nonatomic) app_list::SearchResult* lastOpenedResult; | 29 @property(readonly, nonatomic) app_list::SearchResult* lastOpenedResult; |
28 @property(readonly, nonatomic) int redoSearchCount; | 30 @property(readonly, nonatomic) int redoSearchCount; |
29 | 31 |
30 - (void)quitMessageLoop; | 32 - (void)quitMessageLoop; |
31 | 33 |
32 @end | 34 @end |
33 | 35 |
34 @implementation TestAppsSearchResultsDelegate | 36 @implementation TestAppsSearchResultsDelegate |
(...skipping 10 matching lines...) Expand all Loading... |
45 } | 47 } |
46 | 48 |
47 - (void)redoSearch { | 49 - (void)redoSearch { |
48 ++redoSearchCount_; | 50 ++redoSearchCount_; |
49 } | 51 } |
50 | 52 |
51 - (void)quitMessageLoop { | 53 - (void)quitMessageLoop { |
52 base::MessageLoop::current()->QuitNow(); | 54 base::MessageLoop::current()->QuitNow(); |
53 } | 55 } |
54 | 56 |
| 57 - (void)invokeResultAction:(app_list::SearchResult*)result |
| 58 atIndex:(int)actionIndex { |
| 59 resultForLastInvokedAction_ = result; |
| 60 lastInvokedActinIndex_ = actionIndex; |
| 61 } |
| 62 |
55 @end | 63 @end |
56 | 64 |
57 namespace app_list { | 65 namespace app_list { |
58 namespace test { | 66 namespace test { |
59 namespace { | 67 namespace { |
60 | 68 |
61 const int kDefaultResultsCount = 3; | 69 const int kDefaultResultsCount = 3; |
62 | 70 |
63 class SearchResultWithMenu : public SearchResult { | 71 class SearchResultWithMenu : public SearchResult { |
64 public: | 72 public: |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 ModelResultAt(0)->NotifyItemUninstalled(); | 315 ModelResultAt(0)->NotifyItemUninstalled(); |
308 [delegate_ performSelector:@selector(quitMessageLoop) | 316 [delegate_ performSelector:@selector(quitMessageLoop) |
309 withObject:nil | 317 withObject:nil |
310 afterDelay:0]; | 318 afterDelay:0]; |
311 message_loop.Run(); | 319 message_loop.Run(); |
312 EXPECT_EQ(1, [delegate_ redoSearchCount]); | 320 EXPECT_EQ(1, [delegate_ redoSearchCount]); |
313 } | 321 } |
314 | 322 |
315 } // namespace test | 323 } // namespace test |
316 } // namespace app_list | 324 } // namespace app_list |
OLD | NEW |