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

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

Issue 1984733002: [Reland] GetAccountIdFromProfile() should not return an empty account id if a valid profile is prov… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/chromeos/login/users/mock_user_manager.h"
19 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
18 #include "chrome/browser/notifications/notification_ui_manager.h" 20 #include "chrome/browser/notifications/notification_ui_manager.h"
19 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/test/base/testing_browser_process.h" 22 #include "chrome/test/base/testing_browser_process.h"
21 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
22 #include "chrome/test/base/testing_profile_manager.h" 24 #include "chrome/test/base/testing_profile_manager.h"
23 #include "chromeos/login/login_state.h" 25 #include "chromeos/login/login_state.h"
24 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
25 #include "ui/aura/window_event_dispatcher.h" 27 #include "ui/aura/window_event_dispatcher.h"
26 #include "ui/snapshot/screenshot_grabber.h" 28 #include "ui/snapshot/screenshot_grabber.h"
27 29
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 100
99 private: 101 private:
100 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest); 102 DISALLOW_COPY_AND_ASSIGN(ChromeScreenshotGrabberTest);
101 }; 103 };
102 104
103 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) { 105 TEST_F(ChromeScreenshotGrabberTest, TakeScreenshot) {
104 // Note that within the test framework the LoginState object will always 106 // Note that within the test framework the LoginState object will always
105 // claim that the user did log in. 107 // claim that the user did log in.
106 ASSERT_FALSE(chromeos::LoginState::IsInitialized()); 108 ASSERT_FALSE(chromeos::LoginState::IsInitialized());
107 chromeos::LoginState::Initialize(); 109 chromeos::LoginState::Initialize();
108 110 chromeos::ScopedUserManagerEnabler scoped_enabler(
111 new chromeos::MockUserManager());
109 base::ScopedTempDir directory; 112 base::ScopedTempDir directory;
110 ASSERT_TRUE(directory.CreateUniqueTempDir()); 113 ASSERT_TRUE(directory.CreateUniqueTempDir());
111 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot()); 114 EXPECT_TRUE(chrome_screenshot_grabber()->CanTakeScreenshot());
112 115
113 screenshot_grabber()->TakeScreenshot( 116 screenshot_grabber()->TakeScreenshot(
114 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100), 117 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100),
115 directory.path().AppendASCII("Screenshot.png")); 118 directory.path().AppendASCII("Screenshot.png"));
116 119
117 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot()); 120 EXPECT_FALSE(screenshot_grabber()->CanTakeScreenshot());
118 121
119 Wait(); 122 Wait();
120 123
121 // Screenshot notifications on Windows not yet turned on. 124 // Screenshot notifications on Windows not yet turned on.
122 EXPECT_TRUE(g_browser_process->notification_ui_manager()->FindById( 125 EXPECT_TRUE(g_browser_process->notification_ui_manager()->FindById(
123 std::string("screenshot"), 126 std::string("screenshot"),
124 NotificationUIManager::GetProfileID(profile_)) != NULL); 127 NotificationUIManager::GetProfileID(profile_)) != NULL);
125 g_browser_process->notification_ui_manager()->CancelAll(); 128 g_browser_process->notification_ui_manager()->CancelAll();
126 129
127 EXPECT_EQ(ScreenshotGrabberObserver::SCREENSHOT_SUCCESS, screenshot_result_); 130 EXPECT_EQ(ScreenshotGrabberObserver::SCREENSHOT_SUCCESS, screenshot_result_);
128 131
129 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_) 132 if (ScreenshotGrabberObserver::SCREENSHOT_SUCCESS == screenshot_result_)
130 EXPECT_TRUE(base::PathExists(screenshot_path_)); 133 EXPECT_TRUE(base::PathExists(screenshot_path_));
131 134
132 chromeos::LoginState::Shutdown(); 135 chromeos::LoginState::Shutdown();
133 } 136 }
134 137
135 } // namespace test 138 } // namespace test
136 } // namespace ash 139 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698