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

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

Issue 22715006: Suppressing screenshot messages as long as the login screen is shown and no user is logged in. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test Created 7 years, 4 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 | Annotate | Revision Log
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/screenshot_taker.h" 5 #include "chrome/browser/ui/ash/screenshot_taker.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/notifications/notification_ui_manager.h" 15 #include "chrome/browser/notifications/notification_ui_manager.h"
16 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "chrome/test/base/testing_profile_manager.h" 19 #include "chrome/test/base/testing_profile_manager.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
22 #include "ui/aura/root_window.h" 22 #include "ui/aura/root_window.h"
23 #include "ui/message_center/message_center_switches.h" 23 #include "ui/message_center/message_center_switches.h"
24 24
25 #if defined(OS_CHROMEOS)
26 #include "chromeos/login/login_state.h"
27 #endif
28
25 namespace ash { 29 namespace ash {
26 namespace test { 30 namespace test {
27 31
28 class ScreenshotTakerTest : public AshTestBase, 32 class ScreenshotTakerTest : public AshTestBase,
29 public ScreenshotTakerObserver { 33 public ScreenshotTakerObserver {
30 public: 34 public:
31 ScreenshotTakerTest() 35 ScreenshotTakerTest()
32 : running_(false), 36 : running_(false),
33 screenshot_complete_(false), 37 screenshot_complete_(false),
34 screenshot_result_(ScreenshotTakerObserver::SCREENSHOT_SUCCESS) { 38 screenshot_result_(ScreenshotTakerObserver::SCREENSHOT_SUCCESS) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 bool running_; 91 bool running_;
88 bool screenshot_complete_; 92 bool screenshot_complete_;
89 ScreenshotTakerObserver::Result screenshot_result_; 93 ScreenshotTakerObserver::Result screenshot_result_;
90 base::FilePath screenshot_path_; 94 base::FilePath screenshot_path_;
91 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 95 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
92 96
93 DISALLOW_COPY_AND_ASSIGN(ScreenshotTakerTest); 97 DISALLOW_COPY_AND_ASSIGN(ScreenshotTakerTest);
94 }; 98 };
95 99
96 TEST_F(ScreenshotTakerTest, TakeScreenshot) { 100 TEST_F(ScreenshotTakerTest, TakeScreenshot) {
101 #if defined(OS_CHROMEOS)
102 // Note that within the testframework the LoginState object will always claim
James Cook 2013/08/09 20:09:16 testframework -> test framework
Mr4D (OOO till 08-26) 2013/08/09 20:35:45 Done.
103 // that the user did log in.
104 ASSERT_FALSE(chromeos::LoginState::IsInitialized());
105 chromeos::LoginState::Initialize();
106 #endif
97 scoped_ptr<TestingProfileManager> profile_manager( 107 scoped_ptr<TestingProfileManager> profile_manager(
98 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 108 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
99 ASSERT_TRUE(profile_manager->SetUp()); 109 ASSERT_TRUE(profile_manager->SetUp());
100 TestingProfile* profile = 110 TestingProfile* profile =
101 profile_manager->CreateTestingProfile("test_profile"); 111 profile_manager->CreateTestingProfile("test_profile");
102 ScreenshotTaker screenshot_taker; 112 ScreenshotTaker screenshot_taker;
103 screenshot_taker.AddObserver(this); 113 screenshot_taker.AddObserver(this);
104 base::ScopedTempDir directory; 114 base::ScopedTempDir directory;
105 ASSERT_TRUE(directory.CreateUniqueTempDir()); 115 ASSERT_TRUE(directory.CreateUniqueTempDir());
106 SetScreenshotDirectoryForTest(&screenshot_taker, directory.path()); 116 SetScreenshotDirectoryForTest(&screenshot_taker, directory.path());
107 SetScreenshotBasenameForTest(&screenshot_taker, "Screenshot"); 117 SetScreenshotBasenameForTest(&screenshot_taker, "Screenshot");
108 SetScreenshotProfileForTest(&screenshot_taker, profile); 118 SetScreenshotProfileForTest(&screenshot_taker, profile);
109 119
110 EXPECT_TRUE(screenshot_taker.CanTakeScreenshot()); 120 EXPECT_TRUE(screenshot_taker.CanTakeScreenshot());
111 121
112 screenshot_taker.HandleTakePartialScreenshot( 122 screenshot_taker.HandleTakePartialScreenshot(
113 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100)); 123 Shell::GetPrimaryRootWindow(), gfx::Rect(0, 0, 100, 100));
114 124
115 EXPECT_FALSE(screenshot_taker.CanTakeScreenshot()); 125 EXPECT_FALSE(screenshot_taker.CanTakeScreenshot());
116 126
117 Wait(); 127 Wait();
118 128
119 #if defined(OS_CHROMEOS) 129 #if defined(OS_CHROMEOS)
120 // Screenshot notifications on Windows not yet turned on. 130 // Screenshot notifications on Windows not yet turned on.
121 EXPECT_TRUE(g_browser_process->notification_ui_manager()->FindById( 131 EXPECT_TRUE(g_browser_process->notification_ui_manager()->FindById(
122 std::string("screenshot")) != NULL); 132 std::string("screenshot")) != NULL);
123 g_browser_process->notification_ui_manager()->CancelAll(); 133 g_browser_process->notification_ui_manager()->CancelAll();
134
James Cook 2013/08/09 20:09:16 nit: maybe no blank line here?
Mr4D (OOO till 08-26) 2013/08/09 20:35:45 Done.
124 #endif 135 #endif
125 136
126 EXPECT_EQ(ScreenshotTakerObserver::SCREENSHOT_SUCCESS, screenshot_result_); 137 EXPECT_EQ(ScreenshotTakerObserver::SCREENSHOT_SUCCESS, screenshot_result_);
127 138
128 if (ScreenshotTakerObserver::SCREENSHOT_SUCCESS == screenshot_result_) 139 if (ScreenshotTakerObserver::SCREENSHOT_SUCCESS == screenshot_result_)
129 EXPECT_TRUE(base::PathExists(screenshot_path_)); 140 EXPECT_TRUE(base::PathExists(screenshot_path_));
141
142 #if defined(OS_CHROMEOS)
143 chromeos::LoginState::Shutdown();
144 #endif
130 } 145 }
131 146
132 } // namespace test 147 } // namespace test
133 } // namespace ash 148 } // namespace ash
OLDNEW
« chrome/browser/ui/ash/screenshot_taker.cc ('K') | « chrome/browser/ui/ash/screenshot_taker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698