| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "screen_orientation_dispatcher.h" | 5 #include "screen_orientation_dispatcher.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 LockOrientationResultHolder* results_; | 53 LockOrientationResultHolder* results_; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class ScreenOrientationDispatcherWithSink : public ScreenOrientationDispatcher { | 56 class ScreenOrientationDispatcherWithSink : public ScreenOrientationDispatcher { |
| 57 public: | 57 public: |
| 58 explicit ScreenOrientationDispatcherWithSink(IPC::TestSink* sink) | 58 explicit ScreenOrientationDispatcherWithSink(IPC::TestSink* sink) |
| 59 :ScreenOrientationDispatcher(NULL) , sink_(sink) { | 59 :ScreenOrientationDispatcher(NULL) , sink_(sink) { |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual bool Send(IPC::Message* message) OVERRIDE { | 62 virtual bool Send(IPC::Message* message) override { |
| 63 return sink_->Send(message); | 63 return sink_->Send(message); |
| 64 } | 64 } |
| 65 | 65 |
| 66 IPC::TestSink* sink_; | 66 IPC::TestSink* sink_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 class ScreenOrientationDispatcherTest : public testing::Test { | 69 class ScreenOrientationDispatcherTest : public testing::Test { |
| 70 protected: | 70 protected: |
| 71 virtual void SetUp() OVERRIDE { | 71 virtual void SetUp() override { |
| 72 dispatcher_.reset(new ScreenOrientationDispatcherWithSink(&sink_)); | 72 dispatcher_.reset(new ScreenOrientationDispatcherWithSink(&sink_)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 int GetFirstLockRequestIdFromSink() { | 75 int GetFirstLockRequestIdFromSink() { |
| 76 const IPC::Message* msg = sink().GetFirstMessageMatching( | 76 const IPC::Message* msg = sink().GetFirstMessageMatching( |
| 77 ScreenOrientationHostMsg_LockRequest::ID); | 77 ScreenOrientationHostMsg_LockRequest::ID); |
| 78 EXPECT_TRUE(msg != NULL); | 78 EXPECT_TRUE(msg != NULL); |
| 79 | 79 |
| 80 Tuple2<blink::WebScreenOrientationLockType,int> params; | 80 Tuple2<blink::WebScreenOrientationLockType,int> params; |
| 81 ScreenOrientationHostMsg_LockRequest::Read(msg, ¶ms); | 81 ScreenOrientationHostMsg_LockRequest::Read(msg, ¶ms); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 EXPECT_FALSE(callback_results1.succeeded_); | 237 EXPECT_FALSE(callback_results1.succeeded_); |
| 238 EXPECT_TRUE(callback_results1.failed_); | 238 EXPECT_TRUE(callback_results1.failed_); |
| 239 EXPECT_EQ(blink::WebLockOrientationErrorCanceled, callback_results1.error_); | 239 EXPECT_EQ(blink::WebLockOrientationErrorCanceled, callback_results1.error_); |
| 240 | 240 |
| 241 // Second request is still pending. | 241 // Second request is still pending. |
| 242 EXPECT_FALSE(callback_results2.succeeded_); | 242 EXPECT_FALSE(callback_results2.succeeded_); |
| 243 EXPECT_FALSE(callback_results2.failed_); | 243 EXPECT_FALSE(callback_results2.failed_); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace content | 246 } // namespace content |
| OLD | NEW |