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 | 21 |
21 namespace athena { | 22 namespace athena { |
22 | 23 |
23 aura::Window* GetHomeCardWindow() { | 24 aura::Window* GetHomeCardWindow() { |
24 return static_cast<HomeCardImpl*>(HomeCard::Get())-> | 25 return static_cast<HomeCardImpl*>(HomeCard::Get())-> |
25 GetHomeCardWindowForTest(); | 26 GetHomeCardWindowForTest(); |
26 } | 27 } |
27 | 28 |
28 // Returns true if the keyboard focus is on the search box. | 29 // Returns true if the keyboard focus is on the search box. |
29 bool IsSearchBoxFocused(aura::Window* home_card) { | 30 bool IsSearchBoxFocused(aura::Window* home_card) { |
30 return views::Widget::GetWidgetForNativeWindow(home_card)-> | 31 return views::Widget::GetWidgetForNativeWindow(home_card)-> |
31 GetContentsView()->GetViewByID(kHomeCardSearchBoxId)->HasFocus(); | 32 GetContentsView()->GetViewByID(kHomeCardSearchBoxId)->HasFocus(); |
32 } | 33 } |
33 | 34 |
34 typedef test::AthenaTestBase HomeCardTest; | 35 typedef test::AthenaTestBase HomeCardTest; |
35 | 36 |
36 TEST_F(HomeCardTest, BasicTransition) { | 37 TEST_F(HomeCardTest, BasicTransition) { |
37 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); | 38 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
38 aura::Window* home_card = GetHomeCardWindow(); | 39 aura::Window* home_card = GetHomeCardWindow(); |
39 const int screen_height = root_window()->bounds().height(); | 40 const int screen_height = root_window()->bounds().height(); |
40 const int work_area_height = gfx::Screen::GetScreenFor(root_window())-> | 41 const int work_area_height = gfx::Screen::GetScreenFor(root_window())-> |
41 GetDisplayNearestWindow(root_window()).work_area().height(); | 42 GetDisplayNearestWindow(root_window()).work_area().height(); |
42 ASSERT_TRUE(home_card); | 43 ASSERT_TRUE(home_card); |
43 | 44 |
44 // In the minimized state, home card should be outside (below) the work area. | 45 // In the minimized state, home card should be outside (below) the work area. |
45 EXPECT_EQ(screen_height - kHomeCardMinimizedHeight, | 46 EXPECT_EQ(screen_height - kHomeCardMinimizedHeight, |
46 home_card->GetTargetBounds().y()); | 47 home_card->GetTargetBounds().y()); |
47 EXPECT_EQ(work_area_height, home_card->GetTargetBounds().y()); | 48 EXPECT_EQ(work_area_height, home_card->GetTargetBounds().y()); |
| 49 EXPECT_EQ(wm::ShadowType::SHADOW_TYPE_NONE, wm::GetShadowType(home_card)); |
48 | 50 |
49 WindowManager::GetInstance()->ToggleOverview(); | 51 WindowManager::GetInstance()->ToggleOverview(); |
50 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 52 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
51 EXPECT_EQ(screen_height - kHomeCardHeight, home_card->GetTargetBounds().y()); | 53 EXPECT_EQ(screen_height - kHomeCardHeight, home_card->GetTargetBounds().y()); |
| 54 EXPECT_EQ(wm::ShadowType::SHADOW_TYPE_RECTANGULAR, |
| 55 wm::GetShadowType(home_card)); |
52 | 56 |
53 WindowManager::GetInstance()->ToggleOverview(); | 57 WindowManager::GetInstance()->ToggleOverview(); |
54 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); | 58 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
55 EXPECT_EQ(work_area_height, home_card->GetTargetBounds().y()); | 59 EXPECT_EQ(work_area_height, home_card->GetTargetBounds().y()); |
| 60 EXPECT_EQ(wm::ShadowType::SHADOW_TYPE_NONE, wm::GetShadowType(home_card)); |
56 } | 61 } |
57 | 62 |
58 TEST_F(HomeCardTest, VirtualKeyboardTransition) { | 63 TEST_F(HomeCardTest, VirtualKeyboardTransition) { |
59 // Minimized -> Hidden for virtual keyboard. | 64 // Minimized -> Hidden for virtual keyboard. |
60 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); | 65 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
61 const gfx::Rect vk_bounds(0, 0, 100, 100); | 66 const gfx::Rect vk_bounds(0, 0, 100, 100); |
62 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); | 67 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); |
63 EXPECT_EQ(HomeCard::HIDDEN, HomeCard::Get()->GetState()); | 68 EXPECT_EQ(HomeCard::HIDDEN, HomeCard::Get()->GetState()); |
64 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect()); | 69 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect()); |
65 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); | 70 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
66 | 71 |
67 // bottom -> centered for virtual keyboard. | 72 // bottom -> centered for virtual keyboard. |
68 WindowManager::GetInstance()->ToggleOverview(); | 73 WindowManager::GetInstance()->ToggleOverview(); |
69 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 74 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
70 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); | 75 HomeCard::Get()->UpdateVirtualKeyboardBounds(vk_bounds); |
71 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); | 76 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
72 EXPECT_EQ(0, GetHomeCardWindow()->GetTargetBounds().y()); | 77 |
| 78 aura::Window* home_card = GetHomeCardWindow(); |
| 79 EXPECT_EQ(0, home_card->GetTargetBounds().y()); |
| 80 EXPECT_EQ(wm::ShadowType::SHADOW_TYPE_RECTANGULAR, |
| 81 wm::GetShadowType(home_card)); |
| 82 |
73 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect()); | 83 HomeCard::Get()->UpdateVirtualKeyboardBounds(gfx::Rect()); |
74 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 84 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
75 | 85 |
76 // Overview mode has to finish before ending test, otherwise it crashes. | 86 // Overview mode has to finish before ending test, otherwise it crashes. |
77 // TODO(mukai): fix this. | 87 // TODO(mukai): fix this. |
78 WindowManager::GetInstance()->ToggleOverview(); | 88 WindowManager::GetInstance()->ToggleOverview(); |
79 } | 89 } |
80 | 90 |
81 // Verify if the home card is correctly minimized after app launch. | 91 // Verify if the home card is correctly minimized after app launch. |
82 TEST_F(HomeCardTest, AppSelection) { | 92 TEST_F(HomeCardTest, AppSelection) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 262 |
253 generator.GestureScrollSequence(gfx::Point(x, 10), | 263 generator.GestureScrollSequence(gfx::Point(x, 10), |
254 gfx::Point(x, bottom - 100), | 264 gfx::Point(x, bottom - 100), |
255 base::TimeDelta::FromSeconds(1), | 265 base::TimeDelta::FromSeconds(1), |
256 10); | 266 10); |
257 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 267 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
258 EXPECT_FALSE(IsSearchBoxFocused(home_card)); | 268 EXPECT_FALSE(IsSearchBoxFocused(home_card)); |
259 } | 269 } |
260 | 270 |
261 } // namespace athena | 271 } // namespace athena |
OLD | NEW |