diff options
author | mukai <mukai@chromium.org> | 2014-08-28 11:54:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-28 18:55:35 +0000 |
commit | d2d81b54ffffd5e313d39d7fb5843399dba9a638 (patch) | |
tree | ed610c1f8e01aa8f2bf0f898e0382807f14cacb2 /athena/home | |
parent | 077d1b2059778413e7b10db4fe9f248370136edd (diff) | |
download | chromium_src-d2d81b54ffffd5e313d39d7fb5843399dba9a638.zip chromium_src-d2d81b54ffffd5e313d39d7fb5843399dba9a638.tar.gz chromium_src-d2d81b54ffffd5e313d39d7fb5843399dba9a638.tar.bz2 |
Adds the test expectations of home card bounds.
BUG=403813
R=oshima@chromium.org
TEST=athena_unittests
Review URL: https://codereview.chromium.org/516643005
Cr-Commit-Position: refs/heads/master@{#292430}
Diffstat (limited to 'athena/home')
-rw-r--r-- | athena/home/home_card_impl.cc | 86 | ||||
-rw-r--r-- | athena/home/home_card_impl.h | 118 | ||||
-rw-r--r-- | athena/home/home_card_unittest.cc | 24 |
3 files changed, 152 insertions, 76 deletions
diff --git a/athena/home/home_card_impl.cc b/athena/home/home_card_impl.cc index 85d4eff..bd481f8 100644 --- a/athena/home/home_card_impl.cc +++ b/athena/home/home_card_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "athena/home/public/home_card.h" +#include "athena/home/home_card_impl.h" #include <cmath> #include <limits> @@ -12,27 +12,22 @@ #include "athena/home/app_list_view_delegate.h" #include "athena/home/athena_start_page_view.h" #include "athena/home/home_card_constants.h" -#include "athena/home/home_card_gesture_manager.h" #include "athena/home/minimized_home.h" #include "athena/home/public/app_model_builder.h" -#include "athena/input/public/accelerator_manager.h" #include "athena/screen/public/screen_manager.h" #include "athena/wm/public/window_manager.h" -#include "athena/wm/public/window_manager_observer.h" #include "ui/app_list/search_provider.h" #include "ui/app_list/views/app_list_main_view.h" #include "ui/app_list/views/contents_view.h" #include "ui/aura/layout_manager.h" #include "ui/aura/window.h" #include "ui/compositor/layer.h" -#include "ui/compositor/layer_owner.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/views/layout/fill_layout.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #include "ui/wm/core/shadow_types.h" #include "ui/wm/core/visibility_controller.h" -#include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_client.h" namespace athena { @@ -67,6 +62,8 @@ gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds, return gfx::Rect(); } +} // namespace + // Makes sure the homecard is center-aligned horizontally and bottom-aligned // vertically. class HomeCardLayoutManager : public aura::LayoutManager { @@ -226,73 +223,6 @@ class HomeCardView : public views::WidgetDelegateView { DISALLOW_COPY_AND_ASSIGN(HomeCardView); }; -class HomeCardImpl : public HomeCard, - public AcceleratorHandler, - public HomeCardGestureManager::Delegate, - public WindowManagerObserver, - public aura::client::ActivationChangeObserver { - public: - explicit HomeCardImpl(AppModelBuilder* model_builder); - virtual ~HomeCardImpl(); - - void Init(); - - private: - enum Command { - COMMAND_SHOW_HOME_CARD, - }; - void InstallAccelerators(); - void UpdateMinimizedHomeBounds(); - - // Overridden from HomeCard: - virtual void SetState(State state) OVERRIDE; - virtual State GetState() OVERRIDE; - virtual void RegisterSearchProvider( - app_list::SearchProvider* search_provider) OVERRIDE; - virtual void UpdateVirtualKeyboardBounds( - const gfx::Rect& bounds) OVERRIDE; - - // AcceleratorHandler: - virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; } - virtual bool OnAcceleratorFired(int command_id, - const ui::Accelerator& accelerator) OVERRIDE; - - // HomeCardGestureManager::Delegate: - virtual void OnGestureEnded(State final_state) OVERRIDE; - virtual void OnGestureProgressed( - State from_state, State to_state, float progress) OVERRIDE; - - // WindowManagerObserver: - virtual void OnOverviewModeEnter() OVERRIDE; - virtual void OnOverviewModeExit() OVERRIDE; - virtual void OnActivityOrderHasChanged() OVERRIDE; - - // aura::client::ActivationChangeObserver: - virtual void OnWindowActivated(aura::Window* gained_active, - aura::Window* lost_active) OVERRIDE; - - scoped_ptr<AppModelBuilder> model_builder_; - - HomeCard::State state_; - - // original_state_ is the state which the home card should go back to after - // the virtual keyboard is hidden. - HomeCard::State original_state_; - - views::Widget* home_card_widget_; - HomeCardView* home_card_view_; - scoped_ptr<AppListViewDelegate> view_delegate_; - HomeCardLayoutManager* layout_manager_; - aura::client::ActivationClient* activation_client_; // Not owned - scoped_ptr<ui::LayerOwner> minimized_home_; - - // Right now HomeCard allows only one search provider. - // TODO(mukai): port app-list's SearchController and Mixer. - scoped_ptr<app_list::SearchProvider> search_provider_; - - DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); -}; - HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) : model_builder_(model_builder), state_(HIDDEN), @@ -360,6 +290,10 @@ void HomeCardImpl::Init() { gfx::Insets(0, 0, kHomeCardMinimizedHeight, 0)); } +aura::Window* HomeCardImpl::GetHomeCardWindowForTest() const { + return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; +} + void HomeCardImpl::InstallAccelerators() { const AcceleratorData accelerator_data[] = { {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, @@ -426,6 +360,10 @@ void HomeCardImpl::UpdateVirtualKeyboardBounds( } } +bool HomeCardImpl::IsCommandEnabled(int command_id) const { + return true; +} + bool HomeCardImpl::OnAcceleratorFired(int command_id, const ui::Accelerator& accelerator) { DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); @@ -491,8 +429,6 @@ void HomeCardImpl::OnWindowActivated(aura::Window* gained_active, } } -} // namespace - // static HomeCard* HomeCard::Create(AppModelBuilder* model_builder) { (new HomeCardImpl(model_builder))->Init(); diff --git a/athena/home/home_card_impl.h b/athena/home/home_card_impl.h new file mode 100644 index 0000000..2df940a --- /dev/null +++ b/athena/home/home_card_impl.h @@ -0,0 +1,118 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ATHENA_HOME_HOME_CARD_IMPL_H_ +#define ATHENA_HOME_HOME_CARD_IMPL_H_ + +#include "athena/athena_export.h" +#include "athena/home/home_card_gesture_manager.h" +#include "athena/home/public/home_card.h" +#include "athena/input/public/accelerator_manager.h" +#include "athena/wm/public/window_manager_observer.h" +#include "ui/wm/public/activation_change_observer.h" + +namespace app_list { +class SearchProvider; +} + +namespace aura { +class Window; + +namespace client { +class ActivationClient; +} +} + +namespace gfx { +class Rect; +} + +namespace ui { +class LayerOwner; +} + +namespace views { +class Widget; +} + +namespace athena { +class AppModelBuilder; +class AppListViewDelegate; +class HomeCardLayoutManager; +class HomeCardView; + +class ATHENA_EXPORT HomeCardImpl + : public HomeCard, + public AcceleratorHandler, + public HomeCardGestureManager::Delegate, + public WindowManagerObserver, + public aura::client::ActivationChangeObserver { + public: + explicit HomeCardImpl(AppModelBuilder* model_builder); + virtual ~HomeCardImpl(); + + void Init(); + + aura::Window* GetHomeCardWindowForTest() const; + + private: + enum Command { + COMMAND_SHOW_HOME_CARD, + }; + void InstallAccelerators(); + + // Overridden from HomeCard: + virtual void SetState(HomeCard::State state) OVERRIDE; + virtual State GetState() OVERRIDE; + virtual void RegisterSearchProvider( + app_list::SearchProvider* search_provider) OVERRIDE; + virtual void UpdateVirtualKeyboardBounds( + const gfx::Rect& bounds) OVERRIDE; + + // AcceleratorHandler: + virtual bool IsCommandEnabled(int command_id) const OVERRIDE; + virtual bool OnAcceleratorFired(int command_id, + const ui::Accelerator& accelerator) OVERRIDE; + + // HomeCardGestureManager::Delegate: + virtual void OnGestureEnded(HomeCard::State final_state) OVERRIDE; + virtual void OnGestureProgressed( + HomeCard::State from_state, + HomeCard::State to_state, + float progress) OVERRIDE; + + // WindowManagerObserver: + virtual void OnOverviewModeEnter() OVERRIDE; + virtual void OnOverviewModeExit() OVERRIDE; + virtual void OnActivityOrderHasChanged() OVERRIDE; + + // aura::client::ActivationChangeObserver: + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; + + scoped_ptr<AppModelBuilder> model_builder_; + + HomeCard::State state_; + + // original_state_ is the state which the home card should go back to after + // the virtual keyboard is hidden. + HomeCard::State original_state_; + + views::Widget* home_card_widget_; + HomeCardView* home_card_view_; + scoped_ptr<AppListViewDelegate> view_delegate_; + HomeCardLayoutManager* layout_manager_; + aura::client::ActivationClient* activation_client_; // Not owned + scoped_ptr<ui::LayerOwner> minimized_home_; + + // Right now HomeCard allows only one search provider. + // TODO(mukai): port app-list's SearchController and Mixer. + scoped_ptr<app_list::SearchProvider> search_provider_; + + DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); +}; + +} // namespace athena + +#endif // ATHENA_HOME_HOME_CARD_IMPL_H_ diff --git a/athena/home/home_card_unittest.cc b/athena/home/home_card_unittest.cc index 9db9f08..6365305 100644 --- a/athena/home/home_card_unittest.cc +++ b/athena/home/home_card_unittest.cc @@ -6,23 +6,44 @@ #include "athena/activity/public/activity_factory.h" #include "athena/activity/public/activity_manager.h" +#include "athena/home/home_card_constants.h" +#include "athena/home/home_card_impl.h" #include "athena/test/athena_test_base.h" #include "athena/wm/public/window_manager.h" #include "ui/aura/window.h" #include "ui/events/test/event_generator.h" +#include "ui/gfx/display.h" +#include "ui/gfx/screen.h" namespace athena { +aura::Window* GetHomeCardWindow() { + return static_cast<HomeCardImpl*>(HomeCard::Get())-> + GetHomeCardWindowForTest(); +} + typedef test::AthenaTestBase HomeCardTest; TEST_F(HomeCardTest, BasicTransition) { - EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); + ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); + aura::Window* home_card = GetHomeCardWindow(); + const int screen_height = root_window()->bounds().height(); + const int work_area_height = gfx::Screen::GetScreenFor(root_window())-> + GetDisplayNearestWindow(root_window()).work_area().height(); + ASSERT_TRUE(home_card); + + // In the minimized state, home card should be outside (below) the work area. + EXPECT_EQ(screen_height - kHomeCardMinimizedHeight, + home_card->GetTargetBounds().y()); + EXPECT_EQ(work_area_height, home_card->GetTargetBounds().y()); WindowManager::GetInstance()->ToggleOverview(); EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); + EXPECT_EQ(screen_height - kHomeCardHeight, home_card->GetTargetBounds().y()); WindowManager::GetInstance()->ToggleOverview(); EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); + EXPECT_EQ(work_area_height, home_card->GetTargetBounds().y()); } TEST_F(HomeCardTest, VirtualKeyboardTransition) { @@ -39,6 +60,7 @@ TEST_F(HomeCardTest, VirtualKeyboardTransition) { EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); + EXPECT_EQ(0, GetHomeCardWindow()->GetTargetBounds().y()); HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect()); EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |