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

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

Issue 1880923003: GetAccountIdFromProfile() should not return an empty account id if a valid profile is provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the failed trybots. Created 4 years, 8 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 "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"
28 #include "chromeos/login/login_state.h" 30 #include "chromeos/login/login_state.h"
29 #endif 31 #endif
30 32
31 namespace ash { 33 namespace ash {
32 namespace test { 34 namespace test {
33 35
34 class ChromeScreenshotGrabberTest : public AshTestBase, 36 class ChromeScreenshotGrabberTest : public AshTestBase,
35 public ui::ScreenshotGrabberObserver { 37 public ui::ScreenshotGrabberObserver {
36 public: 38 public:
37 ChromeScreenshotGrabberTest() 39 ChromeScreenshotGrabberTest()
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 private: 104 private:
103 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest); 105 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest);
104 }; 106 };
105 107
106 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) { 108 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) {
107 #if defined(OS_CHROMEOS) 109 #if defined(OS_CHROMEOS)
108 // Note that within the test framework the LoginState object will always 110 // Note that within the test framework the LoginState object will always
109 // claim that the user did log in. 111 // claim that the user did log in.
110 ASSERT_FALSE(chromeos::LoginState::IsInitialized()); 112 ASSERT_FALSE(chromeos::LoginState::IsInitialized());
111 chromeos::LoginState::Initialize(); 113 chromeos::LoginState::Initialize();
114 chromeos::ScopedUserManagerEnabler scoped_enabler(
115 new chromeos::MockUserManager());
112 #endif 116 #endif
113 base::ScopedTempDir directory; 117 base::ScopedTempDir directory;
114 ASSERT_TRUE(directory.CreateUniqueTempDir()); 118 ASSERT_TRUE(directory.CreateUniqueTempDir());
115 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot()); 119 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot());
116 120
117 screenshot_grabber()->TakeScreenshot( 121 screenshot_grabber()->TakeScreenshot(
118 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100), 122 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100),
119 directory.path().AppendASCII("Screenshot.png")); 123 directory.path().AppendASCII("Screenshot.png"));
120 124
121 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot()); 125 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot());
(...skipping 13 matching lines...) Expand all
135 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_) 139 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_)
136 EXPECT_TRUE(base::PathExists(screenshot_path_)); 140 EXPECT_TRUE(base::PathExists(screenshot_path_));
137 141
138 #if defined(OS_CHROMEOS) 142 #if defined(OS_CHROMEOS)
139 chromeos::LoginState::Shutdown(); 143 chromeos::LoginState::Shutdown();
140 #endif 144 #endif
141 } 145 }
142 146
143 } // namespace test 147 } // namespace test
144 } // namespace ash 148 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698