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

Unified Diff: media/remoting/proto_utils_unittest.cc

Issue 2643253003: Media Remoting Clean-up: Less-redundant naming, style consistency, etc. (Closed)
Patch Set: REBASE Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/remoting/proto_utils.cc ('k') | media/remoting/remote_demuxer_stream_adapter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/remoting/proto_utils_unittest.cc
diff --git a/media/remoting/rpc/proto_utils_unittest.cc b/media/remoting/proto_utils_unittest.cc
similarity index 74%
rename from media/remoting/rpc/proto_utils_unittest.cc
rename to media/remoting/proto_utils_unittest.cc
index 71cba9d3fb06938799d1ebfc7d98df0ff515d019..53ab59197d8ad3a1ab9b18d6678faf5edbac584c 100644
--- a/media/remoting/rpc/proto_utils_unittest.cc
+++ b/media/remoting/proto_utils_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/remoting/rpc/proto_utils.h"
+#include "media/remoting/proto_utils.h"
#include <memory>
#include <string>
@@ -19,7 +19,7 @@
#include "media/base/demuxer_stream.h"
#include "media/base/eme_constants.h"
#include "media/base/video_decoder_config.h"
-#include "media/remoting/remoting_rpc_message.pb.h"
+#include "media/remoting/rpc.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -37,14 +37,13 @@ class ProtoUtilsTest : public testing::Test {
TEST_F(ProtoUtilsTest, PassEOSDecoderBuffer) {
// 1. To DecoderBuffer
- scoped_refptr<::media::DecoderBuffer> input_buffer =
- ::media::DecoderBuffer::CreateEOSBuffer();
+ scoped_refptr<DecoderBuffer> input_buffer = DecoderBuffer::CreateEOSBuffer();
// 2. To Byte Array
- std::vector<uint8_t> data = DecoderBufferToByteArray(input_buffer);
+ std::vector<uint8_t> data = DecoderBufferToByteArray(*input_buffer);
// 3. To DecoderBuffer
- scoped_refptr<::media::DecoderBuffer> output_buffer =
+ scoped_refptr<DecoderBuffer> output_buffer =
ByteArrayToDecoderBuffer(data.data(), data.size());
DCHECK(output_buffer);
@@ -71,17 +70,16 @@ TEST_F(ProtoUtilsTest, PassValidDecoderBuffer) {
base::TimeDelta pts = base::TimeDelta::FromMilliseconds(5);
// 1. To DecoderBuffer
- scoped_refptr<::media::DecoderBuffer> input_buffer =
- ::media::DecoderBuffer::CopyFrom(buffer, buffer_size, side_buffer,
- side_buffer_size);
+ scoped_refptr<DecoderBuffer> input_buffer = DecoderBuffer::CopyFrom(
+ buffer, buffer_size, side_buffer, side_buffer_size);
input_buffer->set_timestamp(pts);
input_buffer->set_is_key_frame(true);
// 2. To Byte Array
- std::vector<uint8_t> data = DecoderBufferToByteArray(input_buffer);
+ std::vector<uint8_t> data = DecoderBufferToByteArray(*input_buffer);
// 3. To DecoderBuffer
- scoped_refptr<::media::DecoderBuffer> output_buffer =
+ scoped_refptr<DecoderBuffer> output_buffer =
ByteArrayToDecoderBuffer(data.data(), data.size());
DCHECK(output_buffer);
@@ -120,6 +118,39 @@ TEST_F(ProtoUtilsTest, AudioDecoderConfigConversionTest) {
ASSERT_TRUE(audio_config.Matches(audio_output_config));
}
+TEST_F(ProtoUtilsTest, PipelineStatisticsConversion) {
+ PipelineStatistics original;
+ // Note: Fill the structure with non-zero bytes to ensure this test is
+ // initializing *all* fields.
+ memset(&original, 0xcd, sizeof(original));
+ original.audio_bytes_decoded = 123;
+ original.video_bytes_decoded = 456;
+ original.video_frames_decoded = 789;
+ original.video_frames_dropped = 21;
+ original.audio_memory_usage = 32;
+ original.video_memory_usage = 43;
+ original.video_keyframe_distance_average = base::TimeDelta::Max();
+
+ // There is no convert-to-proto function, so just do that here.
+ pb::PipelineStatistics pb_stats;
+ pb_stats.set_audio_bytes_decoded(original.audio_bytes_decoded);
+ pb_stats.set_video_bytes_decoded(original.video_bytes_decoded);
+ pb_stats.set_video_frames_decoded(original.video_frames_decoded);
+ pb_stats.set_video_frames_dropped(original.video_frames_dropped);
+ pb_stats.set_audio_memory_usage(original.audio_memory_usage);
+ pb_stats.set_video_memory_usage(original.video_memory_usage);
+
+ PipelineStatistics converted;
+ memset(&converted, ~0xcd, sizeof(converted)); // See note above.
+ ConvertProtoToPipelineStatistics(pb_stats, &converted);
+
+ // If this fails, did media::PipelineStatistics add/change fields that are not
+ // being set by media::remoting::ConvertProtoToPipelineStatistics()?
+ EXPECT_EQ(0, memcmp(&original, &converted, sizeof(converted)));
+}
+
+// TODO(miu): Tests for all other conversion functions.
+
TEST_F(ProtoUtilsTest, CdmPromiseResultConversion) {
CdmPromiseResult success_result = CdmPromiseResult::SuccessResult();
« no previous file with comments | « media/remoting/proto_utils.cc ('k') | media/remoting/remote_demuxer_stream_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698