Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: ui/app_list/cocoa/apps_search_box_controller_unittest.mm

Issue 23072036: Adds an integration test for uninstalling app list search results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/cocoa/apps_search_box_controller.mm ('k') | ui/app_list/views/app_list_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_box_controller.h" 5 #import "ui/app_list/cocoa/apps_search_box_controller.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #import "testing/gtest_mac.h" 10 #import "testing/gtest_mac.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Usually localized "Search". 110 // Usually localized "Search".
111 const base::string16 hit_text(ASCIIToUTF16("hint")); 111 const base::string16 hit_text(ASCIIToUTF16("hint"));
112 model->SetHintText(hit_text); 112 model->SetHintText(hit_text);
113 EXPECT_NSEQ(base::SysUTF16ToNSString(hit_text), 113 EXPECT_NSEQ(base::SysUTF16ToNSString(hit_text),
114 [[[apps_search_box_controller_ searchTextField] cell] placeholderString]); 114 [[[apps_search_box_controller_ searchTextField] cell] placeholderString]);
115 115
116 const base::string16 search_text(ASCIIToUTF16("test")); 116 const base::string16 search_text(ASCIIToUTF16("test"));
117 model->SetText(search_text); 117 model->SetText(search_text);
118 EXPECT_NSEQ(base::SysUTF16ToNSString(search_text), 118 EXPECT_NSEQ(base::SysUTF16ToNSString(search_text),
119 [[apps_search_box_controller_ searchTextField] stringValue]); 119 [[apps_search_box_controller_ searchTextField] stringValue]);
120 // Updates coming via the model should not notify the delegate. 120 // Updates coming via the model should notify the delegate.
121 EXPECT_EQ(0, [delegate_ textChangeCount]); 121 EXPECT_EQ(1, [delegate_ textChangeCount]);
122 122
123 // Updates from the view should update the model and notify the delegate. 123 // Updates from the view should update the model and notify the delegate.
124 [apps_search_box_controller_ clearSearch]; 124 [apps_search_box_controller_ clearSearch];
125 EXPECT_EQ(base::string16(), model->text()); 125 EXPECT_EQ(base::string16(), model->text());
126 EXPECT_NSEQ([NSString string], 126 EXPECT_NSEQ([NSString string],
127 [[apps_search_box_controller_ searchTextField] stringValue]); 127 [[apps_search_box_controller_ searchTextField] stringValue]);
128 EXPECT_EQ(1, [delegate_ textChangeCount]); 128 EXPECT_EQ(2, [delegate_ textChangeCount]);
129 129
130 // Test pressing escape clears the search. 130 // Test pressing escape clears the search. First add some text.
131 model->SetText(search_text); 131 model->SetText(search_text);
132 EXPECT_EQ(3, [delegate_ textChangeCount]);
133
132 EXPECT_NSEQ(base::SysUTF16ToNSString(search_text), 134 EXPECT_NSEQ(base::SysUTF16ToNSString(search_text),
133 [[apps_search_box_controller_ searchTextField] stringValue]); 135 [[apps_search_box_controller_ searchTextField] stringValue]);
134 SimulateKeyAction(@selector(complete:)); 136 SimulateKeyAction(@selector(complete:));
135 EXPECT_NSEQ([NSString string], 137 EXPECT_NSEQ([NSString string],
136 [[apps_search_box_controller_ searchTextField] stringValue]); 138 [[apps_search_box_controller_ searchTextField] stringValue]);
137 EXPECT_EQ(2, [delegate_ textChangeCount]); 139 EXPECT_EQ(4, [delegate_ textChangeCount]);
138 } 140 }
139 141
140 // Test the popup menu items. 142 // Test the popup menu items.
141 TEST_F(AppsSearchBoxControllerTest, SearchBoxMenu) { 143 TEST_F(AppsSearchBoxControllerTest, SearchBoxMenu) {
142 NSPopUpButton* menu_control = [apps_search_box_controller_ menuControl]; 144 NSPopUpButton* menu_control = [apps_search_box_controller_ menuControl];
143 EXPECT_TRUE([apps_search_box_controller_ appListMenu]); 145 EXPECT_TRUE([apps_search_box_controller_ appListMenu]);
144 ui::MenuModel* menu_model 146 ui::MenuModel* menu_model
145 = [apps_search_box_controller_ appListMenu]->menu_model(); 147 = [apps_search_box_controller_ appListMenu]->menu_model();
146 // Add one to the item count to account for the blank, first item that Cocoa 148 // Add one to the item count to account for the blank, first item that Cocoa
147 // has in its popup menus. 149 // has in its popup menus.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 base::scoped_nsobject<NSView> current_user_menu_item_; 189 base::scoped_nsobject<NSView> current_user_menu_item_;
188 190
189 private: 191 private:
190 DISALLOW_COPY_AND_ASSIGN(AppsSearchBoxCustomMenuItemTest); 192 DISALLOW_COPY_AND_ASSIGN(AppsSearchBoxCustomMenuItemTest);
191 }; 193 };
192 194
193 TEST_VIEW(AppsSearchBoxCustomMenuItemTest, current_user_menu_item_); 195 TEST_VIEW(AppsSearchBoxCustomMenuItemTest, current_user_menu_item_);
194 196
195 } // namespace test 197 } // namespace test
196 } // namespace app_list 198 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/cocoa/apps_search_box_controller.mm ('k') | ui/app_list/views/app_list_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698