Commit 69895387 authored by tapted@chromium.org's avatar tapted@chromium.org

Clear Search results in the Mac app launcher on close, rather than launch.

The Mac app launcher now fades away when it is dismissed, so the
animation that resets the search state can be seen while it's fading
out. To match Win/CrOS, this CL moves the clear to when the window is
closed; at the end of the animation.

Adds a unit test: AppListWindowControllerTest.CloseClearsSearch to
cover.

BUG=321541
TEST=Launch something from a search in the Mac App Launcher. While it's
fading out you shouldn't see the apps grid slide back in.

Review URL: https://codereview.chromium.org/98233002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238323 0039d316-1c4b-4281-b951-d872f2087c98
parent d1e669f8
......@@ -51,6 +51,9 @@ APP_LIST_EXPORT
BOOL showingSearchResults_;
}
@property(readonly, nonatomic) AppsSearchBoxController*
searchBoxController;
- (app_list::AppListViewDelegate*)delegate;
- (void)setDelegate:(scoped_ptr<app_list::AppListViewDelegate>)newDelegate;
- (void)onSigninStatusChanged;
......@@ -59,6 +62,8 @@ APP_LIST_EXPORT
@interface AppListViewController (TestingAPI)
@property(nonatomic, readonly) BOOL showingSearchResults;
- (AppsGridController*)appsGridController;
- (NSSegmentedControl*)pagerControl;
- (NSView*)backgroundView;
......
......@@ -134,6 +134,14 @@ void AppListModelObserverBridge::OnAppListModelSigninStatusChanged() {
[super dealloc];
}
- (AppsSearchBoxController*)searchBoxController {
return appsSearchBoxController_;
}
- (BOOL)showingSearchResults {
return showingSearchResults_;
}
- (AppsGridController*)appsGridController {
return appsGridController_;
}
......@@ -315,8 +323,6 @@ void AppListModelObserverBridge::OnAppListModelSigninStatusChanged() {
- (void)openResult:(app_list::SearchResult*)result {
if (delegate_)
delegate_->OpenSearchResult(result, 0 /* event flags */);
[appsSearchBoxController_ clearSearch];
}
- (void)redoSearch {
......
......@@ -7,6 +7,7 @@
#include "ui/app_list/app_list_view_delegate.h"
#import "ui/app_list/cocoa/app_list_view_controller.h"
#import "ui/app_list/cocoa/apps_grid_controller.h"
#import "ui/app_list/cocoa/apps_search_box_controller.h"
#include "ui/base/cocoa/window_size_constants.h"
@interface AppListWindow : NSWindow;
......@@ -59,4 +60,8 @@
[appListViewController_ delegate]->Dismiss();
}
- (void)windowWillClose:(NSNotification*)notification {
[[appListViewController_ searchBoxController] clearSearch];
}
@end
......@@ -3,10 +3,12 @@
// found in the LICENSE file.
#import "base/mac/scoped_nsobject.h"
#include "base/strings/utf_string_conversions.h"
#import "testing/gtest_mac.h"
#include "ui/app_list/app_list_view_delegate.h"
#import "ui/app_list/cocoa/app_list_view_controller.h"
#import "ui/app_list/cocoa/app_list_window_controller.h"
#include "ui/app_list/search_box_model.h"
#include "ui/app_list/test/app_list_test_view_delegate.h"
#import "ui/base/test/ui_cocoa_test_helper.h"
......@@ -68,3 +70,26 @@ TEST_F(AppListWindowControllerTest, DismissWithEscape) {
[[controller_ window] cancelOperation:controller_];
EXPECT_EQ(1, delegate()->dismiss_count());
}
// Test that search results are cleared when the window closes, not when a
// search result is selected. If cleared upon selection, the animation showing
// the results sliding away is seen as the window closes, which looks weird.
TEST_F(AppListWindowControllerTest, CloseClearsSearch) {
[[controller_ window] makeKeyAndOrderFront:nil];
app_list::SearchBoxModel* model = delegate()->GetModel()->search_box();
AppListViewController* view_controller = [controller_ appListViewController];
EXPECT_FALSE([view_controller showingSearchResults]);
const base::string16 search_text(ASCIIToUTF16("test"));
model->SetText(search_text);
EXPECT_TRUE([view_controller showingSearchResults]);
EXPECT_EQ(0, delegate()->open_search_result_count());
[view_controller openResult:nil];
EXPECT_EQ(1, delegate()->open_search_result_count());
EXPECT_TRUE([view_controller showingSearchResults]);
[[controller_ window] close]; // Hide.
EXPECT_FALSE([view_controller showingSearchResults]);
}
......@@ -17,6 +17,7 @@ namespace test {
AppListTestViewDelegate::AppListTestViewDelegate()
: dismiss_count_(0),
open_search_result_count_(0),
test_signin_delegate_(NULL),
model_(new AppListTestModel) {
}
......@@ -41,6 +42,11 @@ void AppListTestViewDelegate::GetShortcutPathForApp(
callback.Run(base::FilePath());
}
void AppListTestViewDelegate::OpenSearchResult(SearchResult* result,
int event_flags) {
++open_search_result_count_;
}
void AppListTestViewDelegate::Dismiss() {
++dismiss_count_;
}
......
......@@ -24,6 +24,7 @@ class AppListTestViewDelegate : public AppListViewDelegate {
virtual ~AppListTestViewDelegate();
int dismiss_count() { return dismiss_count_; }
int open_search_result_count() { return open_search_result_count_; }
void set_test_signin_delegate(SigninDelegate* signin_delegate) {
test_signin_delegate_ = signin_delegate;
}
......@@ -43,7 +44,7 @@ class AppListTestViewDelegate : public AppListViewDelegate {
virtual void StartSearch() OVERRIDE {}
virtual void StopSearch() OVERRIDE {}
virtual void OpenSearchResult(SearchResult* result,
int event_flags) OVERRIDE {}
int event_flags) OVERRIDE;
virtual void InvokeSearchResultAction(SearchResult* result,
int action_index,
int event_flags) OVERRIDE {}
......@@ -66,6 +67,7 @@ class AppListTestViewDelegate : public AppListViewDelegate {
private:
int dismiss_count_;
int open_search_result_count_;
Users users_;
SigninDelegate* test_signin_delegate_; // Weak. Owned by test.
scoped_ptr<AppListTestModel> model_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment