| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 : initial_resolution_(initial_resolution), | 44 : initial_resolution_(initial_resolution), |
| 45 current_resolution_(initial_resolution), | 45 current_resolution_(initial_resolution), |
| 46 exact_size_supported_(exact_size_supported), | 46 exact_size_supported_(exact_size_supported), |
| 47 set_resolution_call_count_(0), | 47 set_resolution_call_count_(0), |
| 48 restore_resolution_call_count_(restore_resolution_call_count) { | 48 restore_resolution_call_count_(restore_resolution_call_count) { |
| 49 for (int i = 0; i < num_supported_resolutions; ++i) { | 49 for (int i = 0; i < num_supported_resolutions; ++i) { |
| 50 supported_resolutions_.push_back(supported_resolutions[i]); | 50 supported_resolutions_.push_back(supported_resolutions[i]); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual ~FakeDesktopResizer() { | 54 ~FakeDesktopResizer() override { |
| 55 EXPECT_EQ(initial_resolution_, GetCurrentResolution()); | 55 EXPECT_EQ(initial_resolution_, GetCurrentResolution()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 int set_resolution_call_count() { return set_resolution_call_count_; } | 58 int set_resolution_call_count() { return set_resolution_call_count_; } |
| 59 | 59 |
| 60 // remoting::DesktopResizer interface | 60 // remoting::DesktopResizer interface |
| 61 virtual ScreenResolution GetCurrentResolution() override { | 61 ScreenResolution GetCurrentResolution() override { |
| 62 return current_resolution_; | 62 return current_resolution_; |
| 63 } | 63 } |
| 64 virtual std::list<ScreenResolution> GetSupportedResolutions( | 64 std::list<ScreenResolution> GetSupportedResolutions( |
| 65 const ScreenResolution& preferred) override { | 65 const ScreenResolution& preferred) override { |
| 66 std::list<ScreenResolution> result = supported_resolutions_; | 66 std::list<ScreenResolution> result = supported_resolutions_; |
| 67 if (exact_size_supported_) { | 67 if (exact_size_supported_) { |
| 68 result.push_back(preferred); | 68 result.push_back(preferred); |
| 69 } | 69 } |
| 70 return result; | 70 return result; |
| 71 } | 71 } |
| 72 virtual void SetResolution(const ScreenResolution& resolution) override { | 72 void SetResolution(const ScreenResolution& resolution) override { |
| 73 current_resolution_ = resolution; | 73 current_resolution_ = resolution; |
| 74 ++set_resolution_call_count_; | 74 ++set_resolution_call_count_; |
| 75 } | 75 } |
| 76 virtual void RestoreResolution(const ScreenResolution& resolution) override { | 76 void RestoreResolution(const ScreenResolution& resolution) override { |
| 77 current_resolution_ = resolution; | 77 current_resolution_ = resolution; |
| 78 if (restore_resolution_call_count_) | 78 if (restore_resolution_call_count_) |
| 79 ++(*restore_resolution_call_count_); | 79 ++(*restore_resolution_call_count_); |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 ScreenResolution initial_resolution_; | 83 ScreenResolution initial_resolution_; |
| 84 ScreenResolution current_resolution_; | 84 ScreenResolution current_resolution_; |
| 85 bool exact_size_supported_; | 85 bool exact_size_supported_; |
| 86 std::list<ScreenResolution> supported_resolutions_; | 86 std::list<ScreenResolution> supported_resolutions_; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 FROM_HERE, | 300 FROM_HERE, |
| 301 run_loop.QuitClosure(), | 301 run_loop.QuitClosure(), |
| 302 base::TimeDelta::FromMilliseconds(2)); | 302 base::TimeDelta::FromMilliseconds(2)); |
| 303 run_loop.Run(); | 303 run_loop.Run(); |
| 304 | 304 |
| 305 // If the QuitClosure fired before the final resize, it's a test failure. | 305 // If the QuitClosure fired before the final resize, it's a test failure. |
| 306 EXPECT_EQ(desktop_resizer_->GetCurrentResolution(), MakeResolution(300, 300)); | 306 EXPECT_EQ(desktop_resizer_->GetCurrentResolution(), MakeResolution(300, 300)); |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace remoting | 309 } // namespace remoting |
| OLD | NEW |