| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 // Create an overlay in |overlay_client_| using the current config, but do | 114 // Create an overlay in |overlay_client_| using the current config, but do |
| 115 // not bind anything to |overlay_request_| yet. | 115 // not bind anything to |overlay_request_| yet. |
| 116 void CreateOverlay() { | 116 void CreateOverlay() { |
| 117 EXPECT_CALL(interface_provider_, | 117 EXPECT_CALL(interface_provider_, |
| 118 InterfaceGotten(mojom::AndroidOverlayProvider::Name_)) | 118 InterfaceGotten(mojom::AndroidOverlayProvider::Name_)) |
| 119 .Times(1); | 119 .Times(1); |
| 120 EXPECT_CALL(mock_provider_, OverlayCreated()); | 120 EXPECT_CALL(mock_provider_, OverlayCreated()); |
| 121 | 121 |
| 122 base::UnguessableToken routing_token = base::UnguessableToken::Create(); | 122 base::UnguessableToken routing_token = base::UnguessableToken::Create(); |
| 123 overlay_client_.reset( | 123 overlay_client_.reset(new MojoAndroidOverlay( |
| 124 new MojoAndroidOverlay(&interface_provider_, config_, routing_token)); | 124 &interface_provider_, std::move(config_), routing_token)); |
| 125 base::RunLoop().RunUntilIdle(); | 125 base::RunLoop().RunUntilIdle(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 // Create an overlay, then provide it with |mock_overlay_|. | 128 // Create an overlay, then provide it with |mock_overlay_|. |
| 129 void CreateAndInitializeOverlay() { | 129 void CreateAndInitializeOverlay() { |
| 130 CreateOverlay(); | 130 CreateOverlay(); |
| 131 | 131 |
| 132 // Bind an overlay to the request. | 132 // Bind an overlay to the request. |
| 133 overlay_binding_.Bind(std::move(mock_provider_.overlay_request_)); | 133 overlay_binding_.Bind(std::move(mock_provider_.overlay_request_)); |
| 134 base::RunLoop().RunUntilIdle(); | 134 base::RunLoop().RunUntilIdle(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 161 | 161 |
| 162 // The InterfaceProvider impl that will provide |mock_provider_| to the | 162 // The InterfaceProvider impl that will provide |mock_provider_| to the |
| 163 // overlay client |overlay_client_|. | 163 // overlay client |overlay_client_|. |
| 164 MockInterfaceProvider interface_provider_; | 164 MockInterfaceProvider interface_provider_; |
| 165 | 165 |
| 166 // The client under test. | 166 // The client under test. |
| 167 std::unique_ptr<AndroidOverlay> overlay_client_; | 167 std::unique_ptr<AndroidOverlay> overlay_client_; |
| 168 | 168 |
| 169 // Inital config for |CreateOverlay|. | 169 // Inital config for |CreateOverlay|. |
| 170 // Set to sane values, but feel free to modify before CreateOverlay(). | 170 // Set to sane values, but feel free to modify before CreateOverlay(). |
| 171 AndroidOverlay::Config config_; | 171 AndroidOverlayConfig config_; |
| 172 MockClientCallbacks callbacks_; | 172 MockClientCallbacks callbacks_; |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 // Verify basic create => init => ready => destroyed. | 175 // Verify basic create => init => ready => destroyed. |
| 176 TEST_F(MojoAndroidOverlayTest, CreateInitReadyDestroy) { | 176 TEST_F(MojoAndroidOverlayTest, CreateInitReadyDestroy) { |
| 177 CreateAndInitializeOverlay(); | 177 CreateAndInitializeOverlay(); |
| 178 CreateSurface(); | 178 CreateSurface(); |
| 179 EXPECT_CALL(callbacks_, OnDestroyed(overlay_client_.get())); | 179 EXPECT_CALL(callbacks_, OnDestroyed(overlay_client_.get())); |
| 180 DestroyOverlay(); | 180 DestroyOverlay(); |
| 181 } | 181 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 // Test |secure| makes it to the mojo config when it is false | 223 // Test |secure| makes it to the mojo config when it is false |
| 224 TEST_F(MojoAndroidOverlayTest, SecureFlagIsSentViaMojoWhenFalse) { | 224 TEST_F(MojoAndroidOverlayTest, SecureFlagIsSentViaMojoWhenFalse) { |
| 225 config_.secure = false; | 225 config_.secure = false; |
| 226 CreateOverlay(); | 226 CreateOverlay(); |
| 227 ASSERT_FALSE(mock_provider_.config_->secure); | 227 ASSERT_FALSE(mock_provider_.config_->secure); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace media | 230 } // namespace media |
| OLD | NEW |