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

Side by Side Diff: chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 #include <memory>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/callback_helpers.h" 13 #include "base/callback_helpers.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "chrome/browser/extensions/extension_apitest.h" 19 #include "chrome/browser/extensions/extension_apitest.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 #include "extensions/common/switches.h" 22 #include "extensions/common/switches.h"
23 #include "media/base/bind_to_current_loop.h" 23 #include "media/base/bind_to_current_loop.h"
24 #include "media/base/video_frame.h" 24 #include "media/base/video_frame.h"
25 #include "media/cast/cast_config.h" 25 #include "media/cast/cast_config.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (expected_tones_.empty() && expected_yuv_colors_.empty()) { 149 if (expected_tones_.empty() && expected_yuv_colors_.empty()) {
150 base::ResetAndReturn(&done_callback_).Run(); 150 base::ResetAndReturn(&done_callback_).Run();
151 } else { 151 } else {
152 LOG(INFO) << "Waiting to encounter " << expected_tones_.size() 152 LOG(INFO) << "Waiting to encounter " << expected_tones_.size()
153 << " more tone(s) and " << expected_yuv_colors_.size() 153 << " more tone(s) and " << expected_yuv_colors_.size()
154 << " more color(s)."; 154 << " more color(s).";
155 } 155 }
156 } 156 }
157 157
158 // Invoked by InProcessReceiver for each received audio frame. 158 // Invoked by InProcessReceiver for each received audio frame.
159 void OnAudioFrame(scoped_ptr<media::AudioBus> audio_frame, 159 void OnAudioFrame(std::unique_ptr<media::AudioBus> audio_frame,
160 const base::TimeTicks& playout_time, 160 const base::TimeTicks& playout_time,
161 bool is_continuous) override { 161 bool is_continuous) override {
162 DCHECK(cast_env()->CurrentlyOn(media::cast::CastEnvironment::MAIN)); 162 DCHECK(cast_env()->CurrentlyOn(media::cast::CastEnvironment::MAIN));
163 163
164 if (audio_frame->frames() <= 0) { 164 if (audio_frame->frames() <= 0) {
165 NOTREACHED() << "OnAudioFrame called with no samples?!?"; 165 NOTREACHED() << "OnAudioFrame called with no samples?!?";
166 return; 166 return;
167 } 167 }
168 168
169 if (done_callback_.is_null() || expected_tones_.empty()) 169 if (done_callback_.is_null() || expected_tones_.empty())
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 return result; 290 return result;
291 } 291 }
292 292
293 static uint8_t ComputeMedianIntensityInRegionInPlane(const gfx::Rect& region, 293 static uint8_t ComputeMedianIntensityInRegionInPlane(const gfx::Rect& region,
294 int stride, 294 int stride,
295 const uint8_t* data) { 295 const uint8_t* data) {
296 if (region.IsEmpty()) 296 if (region.IsEmpty())
297 return 0; 297 return 0;
298 const size_t num_values = region.size().GetArea(); 298 const size_t num_values = region.size().GetArea();
299 scoped_ptr<uint8_t[]> values(new uint8_t[num_values]); 299 std::unique_ptr<uint8_t[]> values(new uint8_t[num_values]);
300 for (int y = 0; y < region.height(); ++y) { 300 for (int y = 0; y < region.height(); ++y) {
301 memcpy(values.get() + y * region.width(), 301 memcpy(values.get() + y * region.width(),
302 data + (region.y() + y) * stride + region.x(), 302 data + (region.y() + y) * stride + region.x(),
303 region.width()); 303 region.width());
304 } 304 }
305 const size_t middle_idx = num_values / 2; 305 const size_t middle_idx = num_values / 2;
306 std::nth_element(values.get(), 306 std::nth_element(values.get(),
307 values.get() + middle_idx, 307 values.get() + middle_idx,
308 values.get() + num_values); 308 values.get() + num_values);
309 return values[middle_idx]; 309 return values[middle_idx];
(...skipping 27 matching lines...) Expand all
337 // content and check whether it matches expectations. 337 // content and check whether it matches expectations.
338 // 338 //
339 // TODO(miu): Now that this test has been long-stable on Release build bots, it 339 // TODO(miu): Now that this test has been long-stable on Release build bots, it
340 // should be enabled for the Debug build bots. http://crbug.com/396413 340 // should be enabled for the Debug build bots. http://crbug.com/396413
341 #if defined(NDEBUG) 341 #if defined(NDEBUG)
342 #define MAYBE_EndToEnd EndToEnd 342 #define MAYBE_EndToEnd EndToEnd
343 #else 343 #else
344 #define MAYBE_EndToEnd DISABLED_EndToEnd 344 #define MAYBE_EndToEnd DISABLED_EndToEnd
345 #endif 345 #endif
346 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, MAYBE_EndToEnd) { 346 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, MAYBE_EndToEnd) {
347 scoped_ptr<net::UDPServerSocket> receive_socket( 347 std::unique_ptr<net::UDPServerSocket> receive_socket(
348 new net::UDPServerSocket(NULL, net::NetLog::Source())); 348 new net::UDPServerSocket(NULL, net::NetLog::Source()));
349 receive_socket->AllowAddressReuse(); 349 receive_socket->AllowAddressReuse();
350 ASSERT_EQ(net::OK, receive_socket->Listen(GetFreeLocalPort())); 350 ASSERT_EQ(net::OK, receive_socket->Listen(GetFreeLocalPort()));
351 net::IPEndPoint receiver_end_point; 351 net::IPEndPoint receiver_end_point;
352 ASSERT_EQ(net::OK, receive_socket->GetLocalAddress(&receiver_end_point)); 352 ASSERT_EQ(net::OK, receive_socket->GetLocalAddress(&receiver_end_point));
353 receive_socket.reset(); 353 receive_socket.reset();
354 354
355 // Start the in-process receiver that examines audio/video for the expected 355 // Start the in-process receiver that examines audio/video for the expected
356 // test patterns. 356 // test patterns.
357 const scoped_refptr<media::cast::StandaloneCastEnvironment> cast_environment( 357 const scoped_refptr<media::cast::StandaloneCastEnvironment> cast_environment(
(...skipping 30 matching lines...) Expand all
388 388
389 delete receiver; 389 delete receiver;
390 cast_environment->Shutdown(); 390 cast_environment->Shutdown();
391 } 391 }
392 392
393 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) { 393 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) {
394 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html")); 394 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html"));
395 } 395 }
396 396
397 } // namespace extensions 397 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698