Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/render_widget/blimp_document.h" | 5 #include "blimp/client/core/render_widget/blimp_document.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | 9 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" |
| 10 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" | 10 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" |
| 11 #include "blimp/client/core/input/blimp_input_manager.h" | |
| 11 #include "blimp/client/core/render_widget/blimp_document_manager.h" | 12 #include "blimp/client/core/render_widget/blimp_document_manager.h" |
| 12 #include "blimp/client/core/render_widget/mock_render_widget_feature.h" | 13 #include "blimp/client/core/render_widget/mock_render_widget_feature.h" |
| 13 #include "blimp/client/test/compositor/mock_compositor_dependencies.h" | 14 #include "blimp/client/test/compositor/mock_compositor_dependencies.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using testing::_; | 18 using testing::_; |
| 18 | 19 |
| 19 namespace blimp { | 20 namespace blimp { |
| 20 namespace client { | 21 namespace client { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const int kDefaultContentId = 1; | 24 const int kDefaultContentId = 1; |
| 24 const int kDefaultDocumentId = 1; | |
|
Khushal
2016/10/07 03:40:15
Why remove this?
xingliu
2016/10/10 19:00:17
Moved it back, this is added in the previous patch
| |
| 25 | 25 |
| 26 class MockBlimpDocumentManager : public BlimpDocumentManager { | 26 class MockBlimpDocumentManager : public BlimpDocumentManager { |
| 27 public: | 27 public: |
| 28 explicit MockBlimpDocumentManager( | 28 explicit MockBlimpDocumentManager( |
| 29 RenderWidgetFeature* render_widget_feature, | 29 RenderWidgetFeature* render_widget_feature, |
| 30 BlimpCompositorDependencies* compositor_dependencies) | 30 BlimpCompositorDependencies* compositor_dependencies) |
| 31 : BlimpDocumentManager(kDefaultContentId, | 31 : BlimpDocumentManager(kDefaultContentId, |
| 32 render_widget_feature, | 32 render_widget_feature, |
| 33 compositor_dependencies) {} | 33 compositor_dependencies) {} |
| 34 | 34 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 56 } | 56 } |
| 57 | 57 |
| 58 base::MessageLoop loop_; | 58 base::MessageLoop loop_; |
| 59 BlobImageSerializationProcessor blob_image_serialization_processor_; | 59 BlobImageSerializationProcessor blob_image_serialization_processor_; |
| 60 std::unique_ptr<MockBlimpDocumentManager> document_manager_; | 60 std::unique_ptr<MockBlimpDocumentManager> document_manager_; |
| 61 std::unique_ptr<BlimpCompositorDependencies> compositor_dependencies_; | 61 std::unique_ptr<BlimpCompositorDependencies> compositor_dependencies_; |
| 62 std::unique_ptr<MockRenderWidgetFeature> render_widget_feature_; | 62 std::unique_ptr<MockRenderWidgetFeature> render_widget_feature_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 TEST_F(BlimpDocumentTest, Constructor) { | 65 TEST_F(BlimpDocumentTest, Constructor) { |
| 66 BlimpDocument doc(kDefaultDocumentId, compositor_dependencies_.get(), | 66 BlimpDocument doc(1, compositor_dependencies_.get(), document_manager_.get()); |
| 67 document_manager_.get()); | 67 EXPECT_EQ(doc.document_id(), 1); |
| 68 EXPECT_EQ(doc.document_id(), kDefaultDocumentId); | |
| 69 EXPECT_NE(doc.GetCompositor(), nullptr); | 68 EXPECT_NE(doc.GetCompositor(), nullptr); |
| 70 } | 69 } |
| 71 | 70 |
| 72 TEST_F(BlimpDocumentTest, ForwardMessagesToManager) { | 71 TEST_F(BlimpDocumentTest, ForwardMessagesToManager) { |
| 73 BlimpDocument doc(kDefaultDocumentId, compositor_dependencies_.get(), | 72 BlimpDocument doc(1, compositor_dependencies_.get(), document_manager_.get()); |
| 74 document_manager_.get()); | |
| 75 EXPECT_CALL(*document_manager_, SendCompositorMessage(_, _)).Times(1); | 73 EXPECT_CALL(*document_manager_, SendCompositorMessage(_, _)).Times(1); |
| 76 EXPECT_CALL(*document_manager_, SendWebGestureEvent(_, _)).Times(1); | 74 EXPECT_CALL(*document_manager_, SendWebGestureEvent(_, _)).Times(1); |
| 77 | 75 |
| 78 // When sending messages to the engine, ensure the messages are forwarded | 76 // When sending messages to the engine, ensure the messages are forwarded |
| 79 // to the document manager. | 77 // to the document manager. |
| 80 BlimpCompositorClient* client = static_cast<BlimpCompositorClient*>(&doc); | 78 BlimpCompositorClient* compositor_client = |
| 79 static_cast<BlimpCompositorClient*>(&doc); | |
| 80 cc::proto::CompositorMessage fake_message; | |
| 81 compositor_client->SendCompositorMessage(fake_message); | |
| 81 | 82 |
| 82 cc::proto::CompositorMessage fake_message; | 83 BlimpInputManagerClient* input_manager_client = |
| 83 client->SendCompositorMessage(fake_message); | 84 static_cast<BlimpInputManagerClient*>(&doc); |
| 84 | |
| 85 blink::WebGestureEvent fake_gesture; | 85 blink::WebGestureEvent fake_gesture; |
| 86 client->SendWebGestureEvent(fake_gesture); | 86 input_manager_client->SendWebGestureEvent(fake_gesture); |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace | 89 } // namespace |
| 90 } // namespace client | 90 } // namespace client |
| 91 } // namespace blimp | 91 } // namespace blimp |
| OLD | NEW |