OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "athena/home/public/home_card.h" | 5 #include "athena/home/public/home_card.h" |
6 | 6 |
7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/home/home_card_constants.h" | 9 #include "athena/home/home_card_constants.h" |
10 #include "athena/home/home_card_impl.h" | 10 #include "athena/home/home_card_impl.h" |
11 #include "athena/test/athena_test_base.h" | 11 #include "athena/test/athena_test_base.h" |
12 #include "athena/wm/public/window_manager.h" | 12 #include "athena/wm/public/window_manager.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/events/test/event_generator.h" | 14 #include "ui/events/test/event_generator.h" |
15 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
16 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
17 #include "ui/views/controls/textfield/textfield.h" | 17 #include "ui/views/controls/textfield/textfield.h" |
18 #include "ui/views/focus/focus_manager.h" | 18 #include "ui/views/focus/focus_manager.h" |
19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
20 #include "ui/wm/core/shadow_types.h" | 20 #include "ui/wm/core/shadow_types.h" |
21 #include "ui/wm/core/window_util.h" | |
21 | 22 |
22 namespace athena { | 23 namespace athena { |
23 | 24 |
24 aura::Window* GetHomeCardWindow() { | 25 aura::Window* GetHomeCardWindow() { |
25 return static_cast<HomeCardImpl*>(HomeCard::Get())-> | 26 return static_cast<HomeCardImpl*>(HomeCard::Get())-> |
26 GetHomeCardWindowForTest(); | 27 GetHomeCardWindowForTest(); |
27 } | 28 } |
28 | 29 |
29 // Returns true if the keyboard focus is on the search box. | 30 // Returns true if the keyboard focus is on the search box. |
30 bool IsSearchBoxFocused(aura::Window* home_card) { | 31 bool IsSearchBoxFocused(aura::Window* home_card) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); | 76 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); |
76 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); | 77 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
77 | 78 |
78 aura::Window* home_card = GetHomeCardWindow(); | 79 aura::Window* home_card = GetHomeCardWindow(); |
79 EXPECT_EQ(0, home_card->GetTargetBounds().y()); | 80 EXPECT_EQ(0, home_card->GetTargetBounds().y()); |
80 EXPECT_EQ(wm::ShadowType::SHADOW_TYPE_RECTANGULAR, | 81 EXPECT_EQ(wm::ShadowType::SHADOW_TYPE_RECTANGULAR, |
81 wm::GetShadowType(home_card)); | 82 wm::GetShadowType(home_card)); |
82 | 83 |
83 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect()); | 84 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect()); |
84 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 85 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
86 } | |
85 | 87 |
86 // Overview mode has to finish before ending test, otherwise it crashes. | 88 TEST_F(HomeCardTest, ToggleOverviewWithVirtualKeyboard) { |
87 // TODO(mukai): fix this. | 89 // Minimized -> Hidden for virtual keyboard. |
90 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); | |
91 const gfx::Rect vk_bounds(0, 0, 100, 100); | |
92 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); | |
93 EXPECT_EQ(HomeCard::HIDDEN, HomeCard::Get()->GetState()); | |
94 | |
95 // Toogle overview revives the home card to bottom. Also home card gets | |
pkotwicz
2014/09/11 23:43:16
How about: "Toggling overview revives the bottom h
Jun Mukai
2014/09/11 23:55:02
Done.
| |
96 // active, which will close the virtual keyboard. | |
88 WindowManager::GetInstance()->ToggleOverview(); | 97 WindowManager::GetInstance()->ToggleOverview(); |
98 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | |
99 aura::Window* home_card = GetHomeCardWindow(); | |
100 EXPECT_TRUE(wm::IsActiveWindow(home_card)); | |
89 } | 101 } |
90 | 102 |
91 // Verify if the home card is correctly minimized after app launch. | 103 // Verify if the home card is correctly minimized after app launch. |
92 TEST_F(HomeCardTest, AppSelection) { | 104 TEST_F(HomeCardTest, AppSelection) { |
93 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); | 105 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
94 | 106 |
95 WindowManager::GetInstance()->ToggleOverview(); | 107 WindowManager::GetInstance()->ToggleOverview(); |
96 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 108 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
97 | 109 |
98 athena::ActivityManager::Get()->AddActivity( | 110 athena::ActivityManager::Get()->AddActivity( |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 | 274 |
263 generator.GestureScrollSequence(gfx::Point(x, 10), | 275 generator.GestureScrollSequence(gfx::Point(x, 10), |
264 gfx::Point(x, bottom - 100), | 276 gfx::Point(x, bottom - 100), |
265 base::TimeDelta::FromSeconds(1), | 277 base::TimeDelta::FromSeconds(1), |
266 10); | 278 10); |
267 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 279 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
268 EXPECT_FALSE(IsSearchBoxFocused(home_card)); | 280 EXPECT_FALSE(IsSearchBoxFocused(home_card)); |
269 } | 281 } |
270 | 282 |
271 } // namespace athena | 283 } // namespace athena |
OLD | NEW |