Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1214)

Side by Side Diff: media/mojo/clients/mojo_android_overlay_unittest.cc

Issue 2883913003: Add multiple destruction callbacks to AndroidOverlay. (Closed)
Patch Set: rebased.... though i got not conflicts? Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/mojo/clients/mojo_android_overlay.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 ~MojoAndroidOverlayTest() override {} 74 ~MojoAndroidOverlayTest() override {}
75 75
76 void SetUp() override { 76 void SetUp() override {
77 // Set up default config. 77 // Set up default config.
78 config_.rect = gfx::Rect(100, 200, 300, 400); 78 config_.rect = gfx::Rect(100, 200, 300, 400);
79 config_.ready_cb = base::Bind(&MockClientCallbacks::OnReady, 79 config_.ready_cb = base::Bind(&MockClientCallbacks::OnReady,
80 base::Unretained(&callbacks_)); 80 base::Unretained(&callbacks_));
81 config_.failed_cb = base::Bind(&MockClientCallbacks::OnFailed, 81 config_.failed_cb = base::Bind(&MockClientCallbacks::OnFailed,
82 base::Unretained(&callbacks_)); 82 base::Unretained(&callbacks_));
83 config_.destroyed_cb = base::Bind(&MockClientCallbacks::OnDestroyed,
84 base::Unretained(&callbacks_));
85 83
86 // Make sure that we have an implementation of GpuSurfaceLookup. 84 // Make sure that we have an implementation of GpuSurfaceLookup.
87 gpu::GpuSurfaceTracker::Get(); 85 gpu::GpuSurfaceTracker::Get();
88 } 86 }
89 87
90 void TearDown() override { 88 void TearDown() override {
91 overlay_client_.reset(); 89 overlay_client_.reset();
92 90
93 // If we registered a surface, then unregister it. 91 // If we registered a surface, then unregister it.
94 if (surface_texture_) { 92 if (surface_texture_) {
95 gpu::GpuSurfaceTracker::Get()->RemoveSurface(surface_key_); 93 gpu::GpuSurfaceTracker::Get()->RemoveSurface(surface_key_);
96 // Drop the surface before the surface texture. 94 // Drop the surface before the surface texture.
97 surface_ = gl::ScopedJavaSurface(); 95 surface_ = gl::ScopedJavaSurface();
98 } 96 }
99 97
100 base::RunLoop().RunUntilIdle(); 98 base::RunLoop().RunUntilIdle();
101 } 99 }
102 100
103 // Create an overlay in |overlay_client_| using the current config, but do 101 // Create an overlay in |overlay_client_| using the current config, but do
104 // not bind anything to |overlay_request_| yet. 102 // not bind anything to |overlay_request_| yet.
105 void CreateOverlay() { 103 void CreateOverlay() {
106 EXPECT_CALL(mock_provider_, OverlayCreated()); 104 EXPECT_CALL(mock_provider_, OverlayCreated());
107 105
108 base::UnguessableToken routing_token = base::UnguessableToken::Create(); 106 base::UnguessableToken routing_token = base::UnguessableToken::Create();
109 mojom::AndroidOverlayProviderPtr provider_ptr; 107 mojom::AndroidOverlayProviderPtr provider_ptr;
110 provider_binding_.Bind(mojo::MakeRequest(&provider_ptr)); 108 provider_binding_.Bind(mojo::MakeRequest(&provider_ptr));
111 109
112 overlay_client_.reset(new MojoAndroidOverlay( 110 overlay_client_.reset(new MojoAndroidOverlay(
113 std::move(provider_ptr), std::move(config_), routing_token)); 111 std::move(provider_ptr), std::move(config_), routing_token));
112 overlay_client_->AddSurfaceDestroyedCallback(base::Bind(
113 &MockClientCallbacks::OnDestroyed, base::Unretained(&callbacks_)));
114 base::RunLoop().RunUntilIdle(); 114 base::RunLoop().RunUntilIdle();
115 } 115 }
116 116
117 // Create an overlay, then provide it with |mock_overlay_|. 117 // Create an overlay, then provide it with |mock_overlay_|.
118 void CreateAndInitializeOverlay() { 118 void CreateAndInitializeOverlay() {
119 CreateOverlay(); 119 CreateOverlay();
120 120
121 // Bind an overlay to the request. 121 // Bind an overlay to the request.
122 overlay_binding_.Bind(std::move(mock_provider_.overlay_request_)); 122 overlay_binding_.Bind(std::move(mock_provider_.overlay_request_));
123 base::RunLoop().RunUntilIdle(); 123 base::RunLoop().RunUntilIdle();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 231
232 // Test |secure| makes it to the mojo config when it is false 232 // Test |secure| makes it to the mojo config when it is false
233 TEST_F(MojoAndroidOverlayTest, SecureFlagIsSentViaMojoWhenFalse) { 233 TEST_F(MojoAndroidOverlayTest, SecureFlagIsSentViaMojoWhenFalse) {
234 config_.secure = false; 234 config_.secure = false;
235 CreateOverlay(); 235 CreateOverlay();
236 ASSERT_FALSE(mock_provider_.config_->secure); 236 ASSERT_FALSE(mock_provider_.config_->secure);
237 } 237 }
238 238
239 } // namespace media 239 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/clients/mojo_android_overlay.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698