| 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/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/scoped_testing_local_state.h" | 17 #include "chrome/test/base/scoped_testing_local_state.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/test/test_browser_thread.h" | |
| 22 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
| 23 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
| 24 #include "ui/message_center/message_center_switches.h" | 23 #include "ui/message_center/message_center_switches.h" |
| 25 | 24 |
| 26 namespace ash { | 25 namespace ash { |
| 27 namespace test { | 26 namespace test { |
| 28 | 27 |
| 29 class ScreenshotTakerTest : public AshTestBase, | 28 class ScreenshotTakerTest : public AshTestBase, |
| 30 public ScreenshotTakerObserver { | 29 public ScreenshotTakerObserver { |
| 31 public: | 30 public: |
| 32 ScreenshotTakerTest() | 31 ScreenshotTakerTest() |
| 33 : ui_thread_(content::BrowserThread::UI, message_loop()), | 32 : running_(false), |
| 34 running_(false), | |
| 35 screenshot_complete_(false), | 33 screenshot_complete_(false), |
| 36 screenshot_result_(ScreenshotTakerObserver::SCREENSHOT_SUCCESS) { | 34 screenshot_result_(ScreenshotTakerObserver::SCREENSHOT_SUCCESS) { |
| 37 } | 35 } |
| 38 | 36 |
| 39 virtual void SetUp() { | 37 virtual void SetUp() { |
| 40 AshTestBase::SetUp(); | 38 AshTestBase::SetUp(); |
| 41 local_state_.reset( | 39 local_state_.reset( |
| 42 new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal())); | 40 new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal())); |
| 43 } | 41 } |
| 44 | 42 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void Wait() { | 81 void Wait() { |
| 84 if (screenshot_complete_) | 82 if (screenshot_complete_) |
| 85 return; | 83 return; |
| 86 running_ = true; | 84 running_ = true; |
| 87 message_loop_runner_ = new content::MessageLoopRunner; | 85 message_loop_runner_ = new content::MessageLoopRunner; |
| 88 message_loop_runner_->Run(); | 86 message_loop_runner_->Run(); |
| 89 EXPECT_TRUE(screenshot_complete_); | 87 EXPECT_TRUE(screenshot_complete_); |
| 90 } | 88 } |
| 91 | 89 |
| 92 scoped_ptr<ScopedTestingLocalState> local_state_; | 90 scoped_ptr<ScopedTestingLocalState> local_state_; |
| 93 content::TestBrowserThread ui_thread_; | |
| 94 bool running_; | 91 bool running_; |
| 95 bool screenshot_complete_; | 92 bool screenshot_complete_; |
| 96 ScreenshotTakerObserver::Result screenshot_result_; | 93 ScreenshotTakerObserver::Result screenshot_result_; |
| 97 base::FilePath screenshot_path_; | 94 base::FilePath screenshot_path_; |
| 98 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 95 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 99 | 96 |
| 100 DISALLOW_COPY_AND_ASSIGN(ScreenshotTakerTest); | 97 DISALLOW_COPY_AND_ASSIGN(ScreenshotTakerTest); |
| 101 }; | 98 }; |
| 102 | 99 |
| 103 TEST_F(ScreenshotTakerTest, TakeScreenshot) { | 100 TEST_F(ScreenshotTakerTest, TakeScreenshot) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 127 #endif | 124 #endif |
| 128 | 125 |
| 129 EXPECT_EQ(ScreenshotTakerObserver::SCREENSHOT_SUCCESS, screenshot_result_); | 126 EXPECT_EQ(ScreenshotTakerObserver::SCREENSHOT_SUCCESS, screenshot_result_); |
| 130 | 127 |
| 131 if (ScreenshotTakerObserver::SCREENSHOT_SUCCESS == screenshot_result_) | 128 if (ScreenshotTakerObserver::SCREENSHOT_SUCCESS == screenshot_result_) |
| 132 EXPECT_TRUE(base::PathExists(screenshot_path_)); | 129 EXPECT_TRUE(base::PathExists(screenshot_path_)); |
| 133 } | 130 } |
| 134 | 131 |
| 135 } // namespace test | 132 } // namespace test |
| 136 } // namespace ash | 133 } // namespace ash |
| OLD | NEW |