Skip to content

Commit

Permalink
Enable Zero State by default.
Browse files Browse the repository at this point in the history
Bug: 924785
Change-Id: Ia077d4d43baf974df46baa64632254e95a9ec6b1
Reviewed-on: https://chromium-review.googlesource.com/c/1432883
Commit-Queue: Jenny Zhang <jennyz@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626176}
  • Loading branch information
Jenny Zhang authored and Commit Bot committed Jan 25, 2019
1 parent f23de73 commit 237240f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 15 deletions.
7 changes: 7 additions & 0 deletions ash/app_list/app_list_presenter_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class AppListPresenterDelegateTest : public AshTestBase,
app_list::AppListView::SetShortAnimationForTesting(true);
AshTestBase::SetUp();

// Zeros state changes expected UI behavior. Most test cases in this suite
// are the expected UI behavior with zero state being disabled.
// TODO(jennyz): Add new test cases for zero state, crbug.com/925195.
scoped_feature_list_.InitAndDisableFeature(
app_list_features::kEnableZeroStateSuggestions);
// Make the display big enough to hold the app list.
UpdateDisplay("1024x768");
}
Expand Down Expand Up @@ -141,6 +146,8 @@ class AppListPresenterDelegateTest : public AshTestBase,
}

private:
base::test::ScopedFeatureList scoped_feature_list_;

DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest);
};

Expand Down
13 changes: 12 additions & 1 deletion ash/app_list/views/app_list_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "ash/app_list/views/test/apps_grid_view_test_api.h"
#include "ash/public/cpp/app_list/app_list_config.h"
#include "ash/public/cpp/app_list/app_list_constants.h"
#include "ash/public/cpp/app_list/app_list_features.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
Expand Down Expand Up @@ -543,13 +544,14 @@ class AppListViewFocusTest : public views::ViewsTestBase,

protected:
bool is_rtl_ = false;
base::test::ScopedFeatureList scoped_feature_list_;

private:
AppListView* view_ = nullptr; // Owned by native widget.
SearchResultContainerView* suggestions_container_ =
nullptr; // Owned by view hierarchy.
ExpandArrowView* expand_arrow_view_ = nullptr; // Owned by view hierarchy.
base::test::ScopedFeatureList scoped_feature_list_;

std::unique_ptr<AppListTestViewDelegate> delegate_;
std::unique_ptr<AppsGridViewTestApi> test_api_;
// Restores the locale to default when destructor is called.
Expand Down Expand Up @@ -957,6 +959,14 @@ TEST_F(AppListViewFocusTest, FocusResetAfterStateTransition) {
// Tests that key event which is not handled by focused view will be redirected
// to search box.
TEST_F(AppListViewFocusTest, RedirectFocusToSearchBox) {
// UI behavior is different with Zero State enabled. This test is
// the expected UI behavior with zero state feature being disabled.
// TODO(jennyz): Add new test case for UI behavior for zero state.
// crbug.com/925195.
scoped_feature_list_.InitAndDisableFeature(
app_list_features::kEnableZeroStateSuggestions);
EXPECT_FALSE(app_list_features::IsZeroStateSuggestionsEnabled());

Show();

// Set focus to first suggestion app and type a character.
Expand All @@ -966,6 +976,7 @@ TEST_F(AppListViewFocusTest, RedirectFocusToSearchBox) {
EXPECT_EQ(search_box_view()->search_box()->text(), base::UTF8ToUTF16(" "));
EXPECT_FALSE(search_box_view()->search_box()->HasSelection());

// UI and Focus behavior is different with Zero State enabled.
// Set focus to expand arrow and type a character.
expand_arrow_view()->RequestFocus();
SimulateKeyPress(ui::VKEY_A, false);
Expand Down
23 changes: 18 additions & 5 deletions ash/app_list/views/search_box_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ TEST_F(SearchBoxViewTest, CloseButtonVisibleAfterTyping) {
// activated.
TEST_F(SearchBoxViewTest, CloseButtonInvisibleAfterSearchBoxActived) {
SetSearchBoxActive(true, ui::ET_MOUSE_PRESSED);
EXPECT_FALSE(view()->close_button()->visible());

// UI behavior is different with Zero State enabled.
if (app_list_features::IsZeroStateSuggestionsEnabled())
EXPECT_TRUE(view()->close_button()->visible());
else
EXPECT_FALSE(view()->close_button()->visible());
}

// Tests that the close button becomes invisible after close button is clicked.
Expand Down Expand Up @@ -302,8 +307,12 @@ TEST_F(SearchBoxViewAssistantButtonTest, AssistantButtonVisibleByDefault) {
// Tests that the assistant button is visible after the search box is activated.
TEST_F(SearchBoxViewAssistantButtonTest,
AssistantButtonVisibleAfterSearchBoxActived) {
SetSearchBoxActive(true, ui::ET_MOUSE_PRESSED);
EXPECT_TRUE(view()->assistant_button()->visible());
// Assistant button is not showing up under zero state for now.
// TODO(jennyz): Make assistant button show up under zero state.
if (!app_list_features::IsZeroStateSuggestionsEnabled()) {
SetSearchBoxActive(true, ui::ET_MOUSE_PRESSED);
EXPECT_TRUE(view()->assistant_button()->visible());
}
}

// Tests that the assistant button is invisible after typing in the search box,
Expand All @@ -313,8 +322,12 @@ TEST_F(SearchBoxViewAssistantButtonTest,
KeyPress(ui::VKEY_A);
EXPECT_FALSE(view()->assistant_button()->visible());

KeyPress(ui::VKEY_BACK);
EXPECT_TRUE(view()->assistant_button()->visible());
// Assistant button is not showing up under zero state for now.
// TODO(crbug.com/925455): Make assistant button show up under zero state.
if (!app_list_features::IsZeroStateSuggestionsEnabled()) {
KeyPress(ui::VKEY_BACK);
EXPECT_TRUE(view()->assistant_button()->visible());
}
}

class SearchBoxViewAutocompleteTest
Expand Down
19 changes: 13 additions & 6 deletions ash/app_list/views/search_result_page_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,20 @@ class SearchResultPageViewTest
}

// Setting up the feature set.
if (test_with_answer_card)
scoped_feature_list_.InitAndEnableFeature(
app_list_features::kEnableAnswerCard);
else
scoped_feature_list_.InitAndDisableFeature(
app_list_features::kEnableAnswerCard);
// Zero State will affect the UI behavior significantly. This test works
// if zero state feature is disabled.
// TODO(crbug.com/925195): Add different test suites for zero state.
if (test_with_answer_card) {
scoped_feature_list_.InitWithFeatures(
{app_list_features::kEnableAnswerCard},
{app_list_features::kEnableZeroStateSuggestions});
} else {
scoped_feature_list_.InitWithFeatures(
{}, {app_list_features::kEnableAnswerCard,
app_list_features::kEnableZeroStateSuggestions});
}

ASSERT_FALSE(app_list_features::IsZeroStateSuggestionsEnabled());
ASSERT_EQ(test_with_answer_card, app_list_features::IsAnswerCardEnabled());

// Setting up views.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ class SearchResultTileItemListViewTest
void CreateSearchResultTileItemListView() {
// Enable fullscreen app list for parameterized Play Store app search
// feature.
// Zero State affects the UI behavior significantly. This test tests the
// UI behavior with zero state being disable.
// TODO(crbug.com/925195): Write new test cases for zero state.
if (IsPlayStoreAppSearchEnabled()) {
scoped_feature_list_.InitWithFeatures(
{app_list_features::kEnablePlayStoreAppSearch}, {});
{app_list_features::kEnablePlayStoreAppSearch},
{app_list_features::kEnableZeroStateSuggestions});
} else {
scoped_feature_list_.InitWithFeatures(
{}, {app_list_features::kEnablePlayStoreAppSearch});
{}, {app_list_features::kEnablePlayStoreAppSearch,
app_list_features::kEnableZeroStateSuggestions});
}
ASSERT_EQ(IsPlayStoreAppSearchEnabled(),
app_list_features::IsPlayStoreAppSearchEnabled());
Expand Down
2 changes: 1 addition & 1 deletion ash/public/cpp/app_list/app_list_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const base::Feature kEnableSettingsShortcutSearch{
const base::Feature kEnableAppsGridGapFeature{"EnableAppsGridGapFeature",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kEnableZeroStateSuggestions{
"EnableZeroStateSuggestions", base::FEATURE_DISABLED_BY_DEFAULT};
"EnableZeroStateSuggestions", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kEnableAppListSearchAutocomplete{
"EnableAppListSearchAutocomplete", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kEnableAppSearchResultRanker{
Expand Down
10 changes: 10 additions & 0 deletions chrome/browser/ui/app_list/app_list_client_impl_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

#include <stddef.h>

#include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/app_list/app_list_switches.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/browser_process.h"
Expand Down Expand Up @@ -200,6 +202,14 @@ using AppListClientSearchResultsBrowserTest = extensions::ExtensionBrowserTest;
// Test showing search results, and uninstalling one of them while displayed.
IN_PROC_BROWSER_TEST_F(AppListClientSearchResultsBrowserTest,
UninstallSearchResult) {
// Zero state changes UI behavior. This test case tests the expected UI
// behavior with zero state being disabled.
// TODO(jennyz): write new test case for zero state, crbug.com/925195.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(
app_list_features::kEnableZeroStateSuggestions);
ASSERT_FALSE(app_list_features::IsZeroStateSuggestionsEnabled());

base::FilePath test_extension_path;
ASSERT_TRUE(
base::PathService::Get(chrome::DIR_TEST_DATA, &test_extension_path));
Expand Down

0 comments on commit 237240f

Please sign in to comment.