Skip to content

Commit

Permalink
Fixes the home card state transition for Ctrl-L.
Browse files Browse the repository at this point in the history
- do not hide, toggle between minimized and centered.
- do nothing for other status.

Haven't looked deeply but this also fixes crbug.com/396401

BUG=396401
R=oshima@chromium.org
TEST=manually

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285188 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mukai@chromium.org committed Jul 24, 2014
1 parent bf05058 commit fa86e4f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
7 changes: 4 additions & 3 deletions athena/home/home_card_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,11 @@ class HomeCardImpl : public HomeCard,
virtual bool OnAcceleratorFired(int command_id,
const ui::Accelerator& accelerator) OVERRIDE {
DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id);
if (state_ == HIDDEN)

if (state_ == VISIBLE_CENTERED && original_state_ != VISIBLE_BOTTOM)
SetState(VISIBLE_MINIMIZED);
else if (state_ == VISIBLE_MINIMIZED)
SetState(VISIBLE_CENTERED);
else
SetState(HIDDEN);
return true;
}

Expand Down
28 changes: 28 additions & 0 deletions athena/home/home_card_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "athena/activity/public/activity_manager.h"
#include "athena/test/athena_test_base.h"
#include "athena/wm/public/window_manager.h"
#include "ui/aura/test/event_generator.h"

namespace athena {

Expand Down Expand Up @@ -62,4 +63,31 @@ TEST_F(HomeCardTest, AppSelection) {
WindowManager::GetInstance()->ToggleOverview();
}

TEST_F(HomeCardTest, Accelerators) {
EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());

aura::test::EventGenerator generator(root_window());
generator.PressKey(ui::VKEY_L, ui::EF_CONTROL_DOWN);
EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());

generator.PressKey(ui::VKEY_L, ui::EF_CONTROL_DOWN);
EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());

// Do nothing for BOTTOM.
WindowManager::GetInstance()->ToggleOverview();
EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
generator.PressKey(ui::VKEY_L, ui::EF_CONTROL_DOWN);
EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());

// Do nothing if the centered state is a temporary state.
HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect(0, 0, 100, 100));
EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
generator.PressKey(ui::VKEY_L, ui::EF_CONTROL_DOWN);
EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());

// Overview mode has to finish before ending test, otherwise it crashes.
// TODO(mukai): fix this.
WindowManager::GetInstance()->ToggleOverview();
}

} // namespace athena

0 comments on commit fa86e4f

Please sign in to comment.