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

Side by Side Diff: chrome/browser/ui/ash/chrome_screenshot_grabber_unittest.cc

Issue 1960293003: Remove OS_CHROMEOS from ui/ash code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
OLDNEW
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 "chromeos/login/login_state.h"
23 #include "content/public/test/test_utils.h" 24 #include "content/public/test/test_utils.h"
24 #include "ui/aura/window_event_dispatcher.h" 25 #include "ui/aura/window_event_dispatcher.h"
25 #include "ui/snapshot/screenshot_grabber.h" 26 #include "ui/snapshot/screenshot_grabber.h"
26 27
27 #if defined(OS_CHROMEOS)
28 #include "chromeos/login/login_state.h"
29 #endif
30
31 namespace ash { 28 namespace ash {
32 namespace test { 29 namespace test {
33 30
34 class ChromeScreenshotGrabberTest : public AshTestBase, 31 class ChromeScreenshotGrabberTest : public AshTestBase,
35 public ui::ScreenshotGrabberObserver { 32 public ui::ScreenshotGrabberObserver {
36 public: 33 public:
37 ChromeScreenshotGrabberTest() 34 ChromeScreenshotGrabberTest()
38 : profile_(NULL), 35 : profile_(NULL),
39 running_(false), 36 running_(false),
40 screenshot_complete_(false), 37 screenshot_complete_(false),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ScreenshotGrabberObserver::Result screenshot_result_; 94 ScreenshotGrabberObserver::Result screenshot_result_;
98 std::unique_ptr<ChromeScreenshotGrabber> chrome_screenshot_grabber_; 95 std::unique_ptr<ChromeScreenshotGrabber> chrome_screenshot_grabber_;
99 base::FilePath screenshot_path_; 96 base::FilePath screenshot_path_;
100 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 97 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
101 98
102 private: 99 private:
103 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest); 100 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest);
104 }; 101 };
105 102
106 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) { 103 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) {
107 #if defined(OS_CHROMEOS)
108 // Note that within the test framework the LoginState object will always 104 // Note that within the test framework the LoginState object will always
109 // claim that the user did log in. 105 // claim that the user did log in.
110 ASSERT_FALSE(chromeos::LoginState::IsInitialized()); 106 ASSERT_FALSE(chromeos::LoginState::IsInitialized());
111 chromeos::LoginState::Initialize(); 107 chromeos::LoginState::Initialize();
112 #endif 108
113 base::ScopedTempDir directory; 109 base::ScopedTempDir directory;
114 ASSERT_TRUE(directory.CreateUniqueTempDir()); 110 ASSERT_TRUE(directory.CreateUniqueTempDir());
115 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot()); 111 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot());
116 112
117 screenshot_grabber()->TakeScreenshot( 113 screenshot_grabber()->TakeScreenshot(
118 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100), 114 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100),
119 directory.path().AppendASCII("Screenshot.png")); 115 directory.path().AppendASCII("Screenshot.png"));
120 116
121 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot()); 117 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot());
122 118
123 Wait(); 119 Wait();
124 120
125 #if defined(OS_CHROMEOS)
126 // Screenshot notifications on Windows not yet turned on. 121 // Screenshot notifications on Windows not yet turned on.
127 EXPECT_TRUE(g_browser_process->notification_ui_manager()->FindById( 122 EXPECT_TRUE(g_browser_process->notification_ui_manager()->FindById(
128 std::string("screenshot"), 123 std::string("screenshot"),
129 NotificationUIManager::GetProfileID(profile_)) != NULL); 124 NotificationUIManager::GetProfileID(profile_)) != NULL);
130 g_browser_process->notification_ui_manager()->CancelAll(); 125 g_browser_process->notification_ui_manager()->CancelAll();
131 #endif
132 126
133 EXPECT_EQ(ScreenshotGrabberObserver::SCREENSHOT_SUCCESS, screenshot_result_); 127 EXPECT_EQ(ScreenshotGrabberObserver::SCREENSHOT_SUCCESS, screenshot_result_);
134 128
135 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_) 129 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_)
136 EXPECT_TRUE(base::PathExists(screenshot_path_)); 130 EXPECT_TRUE(base::PathExists(screenshot_path_));
137 131
138 #if defined(OS_CHROMEOS)
139 chromeos::LoginState::Shutdown(); 132 chromeos::LoginState::Shutdown();
140 #endif
141 } 133 }
142 134
143 } // namespace test 135 } // namespace test
144 } // namespace ash 136 } // namespace ash
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_screenshot_grabber.cc ('k') | chrome/browser/ui/ash/chrome_shell_content_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698