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 "ash/utility/partial_screenshot_controller.h" | 5 #include "ash/utility/partial_screenshot_controller.h" |
6 | 6 |
7 #include "ash/display/cursor_window_controller.h" | 7 #include "ash/display/cursor_window_controller.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/screenshot_delegate.h" | 9 #include "ash/screenshot_delegate.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 protected: | 26 protected: |
27 PartialScreenshotController* partial_screenshot_controller() { | 27 PartialScreenshotController* partial_screenshot_controller() { |
28 return Shell::GetInstance()->partial_screenshot_controller(); | 28 return Shell::GetInstance()->partial_screenshot_controller(); |
29 } | 29 } |
30 | 30 |
31 void StartPartialScreenshotSession() { | 31 void StartPartialScreenshotSession() { |
32 partial_screenshot_controller()->StartPartialScreenshotSession( | 32 partial_screenshot_controller()->StartPartialScreenshotSession( |
33 GetScreenshotDelegate()); | 33 GetScreenshotDelegate()); |
34 } | 34 } |
35 | 35 |
| 36 void Cancel() { partial_screenshot_controller()->Cancel(); } |
| 37 |
36 bool IsActive() { | 38 bool IsActive() { |
37 return partial_screenshot_controller()->screenshot_delegate_ != nullptr; | 39 return partial_screenshot_controller()->screenshot_delegate_ != nullptr; |
38 } | 40 } |
39 | 41 |
40 const gfx::Point& GetStartPosition() const { | 42 const gfx::Point& GetStartPosition() const { |
41 return Shell::GetInstance() | 43 return Shell::GetInstance() |
42 ->partial_screenshot_controller() | 44 ->partial_screenshot_controller() |
43 ->start_position_; | 45 ->start_position_; |
44 } | 46 } |
45 | 47 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 EXPECT_FALSE(IsActive()); | 136 EXPECT_FALSE(IsActive()); |
135 | 137 |
136 StartPartialScreenshotSession(); | 138 StartPartialScreenshotSession(); |
137 EXPECT_TRUE(IsActive()); | 139 EXPECT_TRUE(IsActive()); |
138 UpdateDisplay("400x400"); | 140 UpdateDisplay("400x400"); |
139 RunAllPendingInMessageLoop(); | 141 RunAllPendingInMessageLoop(); |
140 EXPECT_FALSE(IsActive()); | 142 EXPECT_FALSE(IsActive()); |
141 } | 143 } |
142 | 144 |
143 #if defined(OS_CHROMEOS) | 145 #if defined(OS_CHROMEOS) |
| 146 TEST_F(PartialScreenshotControllerTest, VisibilityTest) { |
| 147 aura::client::CursorClient* client = Shell::GetInstance()->cursor_manager(); |
| 148 |
| 149 GetEventGenerator().PressKey(ui::VKEY_A, 0); |
| 150 GetEventGenerator().ReleaseKey(ui::VKEY_A, 0); |
| 151 |
| 152 EXPECT_FALSE(client->IsCursorVisible()); |
| 153 |
| 154 StartPartialScreenshotSession(); |
| 155 EXPECT_TRUE(IsActive()); |
| 156 EXPECT_TRUE(client->IsCursorVisible()); |
| 157 |
| 158 Cancel(); |
| 159 EXPECT_TRUE(client->IsCursorVisible()); |
| 160 } |
| 161 |
144 // Make sure PartialScreenshotController doesn't prevent handling of large | 162 // Make sure PartialScreenshotController doesn't prevent handling of large |
145 // cursor. See http://crbug.com/459214 | 163 // cursor. See http://crbug.com/459214 |
146 TEST_F(PartialScreenshotControllerTest, LargeCursor) { | 164 TEST_F(PartialScreenshotControllerTest, LargeCursor) { |
147 Shell::GetInstance()->cursor_manager()->SetCursorSet(ui::CURSOR_SET_LARGE); | 165 Shell::GetInstance()->cursor_manager()->SetCursorSet(ui::CURSOR_SET_LARGE); |
148 Shell::GetInstance() | 166 Shell::GetInstance() |
149 ->display_controller() | 167 ->display_controller() |
150 ->cursor_window_controller() | 168 ->cursor_window_controller() |
151 ->SetCursorCompositingEnabled(true); | 169 ->SetCursorCompositingEnabled(true); |
152 | 170 |
153 // Large cursor is represented as cursor window. | 171 // Large cursor is represented as cursor window. |
(...skipping 23 matching lines...) Expand all Loading... |
177 event_generator.ReleaseLeftButton(); | 195 event_generator.ReleaseLeftButton(); |
178 | 196 |
179 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); | 197 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); |
180 EXPECT_EQ("1,1 5x5", GetScreenshotDelegate()->last_rect().ToString()); | 198 EXPECT_EQ("1,1 5x5", GetScreenshotDelegate()->last_rect().ToString()); |
181 RunAllPendingInMessageLoop(); | 199 RunAllPendingInMessageLoop(); |
182 EXPECT_FALSE(IsActive()); | 200 EXPECT_FALSE(IsActive()); |
183 } | 201 } |
184 #endif | 202 #endif |
185 | 203 |
186 } // namespace ash | 204 } // namespace ash |
OLD | NEW |