| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/ash/chrome_screenshot_grabber.h" | 5 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 22 #include "chrome/test/base/testing_profile_manager.h" | 22 #include "chrome/test/base/testing_profile_manager.h" |
| 23 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
| 24 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
| 25 #include "ui/snapshot/screenshot_grabber.h" | 25 #include "ui/snapshot/screenshot_grabber.h" |
| 26 | 26 |
| 27 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
| 28 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | |
| 29 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | |
| 30 #include "chromeos/login/login_state.h" | 28 #include "chromeos/login/login_state.h" |
| 31 #endif | 29 #endif |
| 32 | 30 |
| 33 namespace ash { | 31 namespace ash { |
| 34 namespace test { | 32 namespace test { |
| 35 | 33 |
| 36 class ChromeScreenshotGrabberTest : public AshTestBase, | 34 class ChromeScreenshotGrabberTest : public AshTestBase, |
| 37 public ui::ScreenshotGrabberObserver { | 35 public ui::ScreenshotGrabberObserver { |
| 38 public: | 36 public: |
| 39 ChromeScreenshotGrabberTest() | 37 ChromeScreenshotGrabberTest() |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 private: | 102 private: |
| 105 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest); | 103 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest); |
| 106 }; | 104 }; |
| 107 | 105 |
| 108 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) { | 106 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) { |
| 109 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
| 110 // Note that within the test framework the LoginState object will always | 108 // Note that within the test framework the LoginState object will always |
| 111 // claim that the user did log in. | 109 // claim that the user did log in. |
| 112 ASSERT_FALSE(chromeos::LoginState::IsInitialized()); | 110 ASSERT_FALSE(chromeos::LoginState::IsInitialized()); |
| 113 chromeos::LoginState::Initialize(); | 111 chromeos::LoginState::Initialize(); |
| 114 chromeos::ScopedUserManagerEnabler scoped_enabler( | |
| 115 new chromeos::MockUserManager()); | |
| 116 #endif | 112 #endif |
| 117 base::ScopedTempDir directory; | 113 base::ScopedTempDir directory; |
| 118 ASSERT_TRUE(directory.CreateUniqueTempDir()); | 114 ASSERT_TRUE(directory.CreateUniqueTempDir()); |
| 119 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot()); | 115 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot()); |
| 120 | 116 |
| 121 screenshot_grabber()->TakeScreenshot( | 117 screenshot_grabber()->TakeScreenshot( |
| 122 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100), | 118 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100), |
| 123 directory.path().AppendASCII("Screenshot.png")); | 119 directory.path().AppendASCII("Screenshot.png")); |
| 124 | 120 |
| 125 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot()); | 121 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 139 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_) | 135 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_) |
| 140 EXPECT_TRUE(base::PathExists(screenshot_path_)); | 136 EXPECT_TRUE(base::PathExists(screenshot_path_)); |
| 141 | 137 |
| 142 #if defined(OS_CHROMEOS) | 138 #if defined(OS_CHROMEOS) |
| 143 chromeos::LoginState::Shutdown(); | 139 chromeos::LoginState::Shutdown(); |
| 144 #endif | 140 #endif |
| 145 } | 141 } |
| 146 | 142 |
| 147 } // namespace test | 143 } // namespace test |
| 148 } // namespace ash | 144 } // namespace ash |
| OLD | NEW |