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

Side by Side Diff: athena/home/home_card_unittest.cc

Issue 408623003: Minimize HomeCard if the user opens something in the home card. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 6 years, 5 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "athena/home/public/home_card.h"
6
7 #include "athena/activity/public/activity_factory.h"
8 #include "athena/activity/public/activity_manager.h"
9 #include "athena/test/athena_test_base.h"
10 #include "athena/wm/public/window_manager.h"
11 #include "base/command_line.h"
12 #include "ui/app_list/app_list_switches.h"
13
14 namespace athena {
15 namespace {
16
17 class HomeCardTest : public test::AthenaTestBase {
18 public:
19 HomeCardTest() {}
20 virtual ~HomeCardTest() {}
21
22 virtual void SetUp() OVERRIDE {
23 // Force showing in the experimental app-list view.
24 base::CommandLine::ForCurrentProcess()->AppendSwitch(
25 app_list::switches::kEnableExperimentalAppList);
oshima 2014/07/22 21:48:38 please move this to the helper as discussed offlin
Jun Mukai 2014/07/22 21:57:57 Done.
26
27 test::AthenaTestBase::SetUp();
28 }
29
30 private:
31 DISALLOW_COPY_AND_ASSIGN(HomeCardTest);
32 };
33
34 TEST_F(HomeCardTest, BasicTransition) {
35 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
36
37 WindowManager::GetInstance()->ToggleOverview();
38 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
39
40 WindowManager::GetInstance()->ToggleOverview();
41 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
42 }
43
44 TEST_F(HomeCardTest, VirtualKeyboardTransition) {
45 // Minimized -> Hidden for virtual keyboard.
46 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
47 const gfx::Rect vk_bounds(0, 0, 100, 100);
48 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds);
49 EXPECT_EQ(HomeCard::HIDDEN, HomeCard::Get()->GetState());
50 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect());
51 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
52
53 // bottom -> centered for virtual keyboard.
54 WindowManager::GetInstance()->ToggleOverview();
55 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
56 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds);
57 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
58 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect());
59 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
60
61 // Overview mode has to finish before ending test, otherwise it crashes.
62 // TODO(mukai): fix this.
63 WindowManager::GetInstance()->ToggleOverview();
64 }
65
66 // Verify if the home card is correctly minimized after app launch.
67 TEST_F(HomeCardTest, AppSelection) {
68 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
69
70 WindowManager::GetInstance()->ToggleOverview();
71 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
72
73 athena::ActivityManager::Get()->AddActivity(
74 athena::ActivityFactory::Get()->CreateWebActivity(
75 NULL, GURL("http://www.google.com/")));
76 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
77
78 // Overview mode has to finish before ending test, otherwise it crashes.
79 // TODO(mukai): fix this.
80 WindowManager::GetInstance()->ToggleOverview();
81 }
82
83 } // namespace
oshima 2014/07/22 21:48:37 please move the tests out from anonymous namespace
Jun Mukai 2014/07/22 21:57:57 Done.
84 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698