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

Side by Side Diff: media/filters/ffmpeg_glue_unittest.cc

Issue 126170: Make the generated stubs weak. Enable the unittests that had conflicting symbols. (Closed)
Patch Set: Fix indent.w Created 11 years, 6 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "media/base/filters.h" 5 #include "media/base/filters.h"
6 #include "media/base/mock_media_filters.h" 6 #include "media/base/mock_media_filters.h"
7 #include "media/filters/ffmpeg_common.h" 7 #include "media/filters/ffmpeg_common.h"
8 #include "media/filters/ffmpeg_glue.h" 8 #include "media/filters/ffmpeg_glue.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 EXPECT_TRUE(g_protocol->url_write); 48 EXPECT_TRUE(g_protocol->url_write);
49 } 49 }
50 50
51 TEST(FFmpegGlueTest, AddRemoveGetDataSource) { 51 TEST(FFmpegGlueTest, AddRemoveGetDataSource) {
52 // Prepare testing data. 52 // Prepare testing data.
53 media::FFmpegGlue* glue = media::FFmpegGlue::get(); 53 media::FFmpegGlue* glue = media::FFmpegGlue::get();
54 54
55 // Create our data sources and add them to the glue layer. 55 // Create our data sources and add them to the glue layer.
56 bool deleted_a = false; 56 bool deleted_a = false;
57 bool deleted_b = false; 57 bool deleted_b = false;
58 media::MockFilterConfig config_a; 58 media::old_mocks::MockFilterConfig config_a;
59 media::MockFilterConfig config_b; 59 media::old_mocks::MockFilterConfig config_b;
60 scoped_refptr<media::MockDataSource> data_source_a 60 scoped_refptr<media::old_mocks::MockDataSource> data_source_a
61 = new media::MockDataSource(&config_a, &deleted_a); 61 = new media::old_mocks::MockDataSource(&config_a, &deleted_a);
62 scoped_refptr<media::MockDataSource> data_source_b 62 scoped_refptr<media::old_mocks::MockDataSource> data_source_b
63 = new media::MockDataSource(&config_b, &deleted_b); 63 = new media::old_mocks::MockDataSource(&config_b, &deleted_b);
64 64
65 // Make sure the keys are unique. 65 // Make sure the keys are unique.
66 std::string key_a = glue->AddDataSource(data_source_a); 66 std::string key_a = glue->AddDataSource(data_source_a);
67 std::string key_b = glue->AddDataSource(data_source_b); 67 std::string key_b = glue->AddDataSource(data_source_b);
68 EXPECT_EQ(0, key_a.find("http://")); 68 EXPECT_EQ(0u, key_a.find("http://"));
69 EXPECT_EQ(0, key_b.find("http://")); 69 EXPECT_EQ(0u, key_b.find("http://"));
70 EXPECT_NE(key_a, key_b); 70 EXPECT_NE(key_a, key_b);
71 71
72 // Our keys should return our data sources. 72 // Our keys should return our data sources.
73 scoped_refptr<media::DataSource> data_source_c; 73 scoped_refptr<media::DataSource> data_source_c;
74 scoped_refptr<media::DataSource> data_source_d; 74 scoped_refptr<media::DataSource> data_source_d;
75 glue->GetDataSource(key_a, &data_source_c); 75 glue->GetDataSource(key_a, &data_source_c);
76 glue->GetDataSource(key_b, &data_source_d); 76 glue->GetDataSource(key_b, &data_source_d);
77 EXPECT_EQ(data_source_a, data_source_c); 77 EXPECT_EQ(data_source_a, data_source_c);
78 EXPECT_EQ(data_source_b, data_source_d); 78 EXPECT_EQ(data_source_b, data_source_d);
79 79
(...skipping 21 matching lines...) Expand all
101 EXPECT_TRUE(deleted_a); 101 EXPECT_TRUE(deleted_a);
102 EXPECT_TRUE(deleted_b); 102 EXPECT_TRUE(deleted_b);
103 } 103 }
104 104
105 TEST(FFmpegGlueTest, OpenClose) { 105 TEST(FFmpegGlueTest, OpenClose) {
106 // Prepare testing data. 106 // Prepare testing data.
107 media::FFmpegGlue* glue = media::FFmpegGlue::get(); 107 media::FFmpegGlue* glue = media::FFmpegGlue::get();
108 108
109 // Create our data source and add them to the glue layer. 109 // Create our data source and add them to the glue layer.
110 bool deleted = false; 110 bool deleted = false;
111 media::MockFilterConfig config; 111 media::old_mocks::MockFilterConfig config;
112 scoped_refptr<media::MockDataSource> data_source 112 scoped_refptr<media::old_mocks::MockDataSource> data_source
113 = new media::MockDataSource(&config, &deleted); 113 = new media::old_mocks::MockDataSource(&config, &deleted);
114 std::string key = glue->AddDataSource(data_source); 114 std::string key = glue->AddDataSource(data_source);
115 115
116 // Prepare FFmpeg URLContext structure. 116 // Prepare FFmpeg URLContext structure.
117 URLContext context; 117 URLContext context;
118 memset(&context, 0, sizeof(context)); 118 memset(&context, 0, sizeof(context));
119 119
120 // Test opening a URLContext with a data source that doesn't exist. 120 // Test opening a URLContext with a data source that doesn't exist.
121 EXPECT_EQ(AVERROR_IO, g_protocol->url_open(&context, "foobar", 0)); 121 EXPECT_EQ(AVERROR_IO, g_protocol->url_open(&context, "foobar", 0));
122 122
123 // Test opening a URLContext with our data source. 123 // Test opening a URLContext with our data source.
(...skipping 16 matching lines...) Expand all
140 } 140 }
141 141
142 TEST(FFmpegGlueTest, ReadingWriting) { 142 TEST(FFmpegGlueTest, ReadingWriting) {
143 // Prepare testing data. 143 // Prepare testing data.
144 media::FFmpegGlue* glue = media::FFmpegGlue::get(); 144 media::FFmpegGlue* glue = media::FFmpegGlue::get();
145 const size_t kBufferSize = 16; 145 const size_t kBufferSize = 16;
146 unsigned char buffer[kBufferSize]; 146 unsigned char buffer[kBufferSize];
147 147
148 // Configure MockDataSource to be 8 characters long and fill reads with 148 // Configure MockDataSource to be 8 characters long and fill reads with
149 // periods. Therefore our expected string should be a character of 8 periods. 149 // periods. Therefore our expected string should be a character of 8 periods.
150 const size_t kExpectedSize = 8; 150 const int kExpectedSize = 8;
151 media::MockFilterConfig config; 151 media::old_mocks::MockFilterConfig config;
152 config.media_total_bytes = kExpectedSize; 152 config.media_total_bytes = kExpectedSize;
153 config.data_source_value = '.'; 153 config.data_source_value = '.';
154 const char kExpected[] = "........"; 154 const char kExpected[] = "........";
155 COMPILE_ASSERT(kExpectedSize == (arraysize(kExpected) - 1), string_length); 155 COMPILE_ASSERT(kExpectedSize == (arraysize(kExpected) - 1), string_length);
156 156
157 // Create our data source and add them to the glue layer. 157 // Create our data source and add them to the glue layer.
158 bool deleted = false; 158 bool deleted = false;
159 scoped_refptr<media::MockDataSource> data_source 159 scoped_refptr<media::old_mocks::MockDataSource> data_source
160 = new media::MockDataSource(&config, &deleted); 160 = new media::old_mocks::MockDataSource(&config, &deleted);
161 std::string key = glue->AddDataSource(data_source); 161 std::string key = glue->AddDataSource(data_source);
162 162
163 // Open our data source and then remove it from the glue layer. 163 // Open our data source and then remove it from the glue layer.
164 URLContext context; 164 URLContext context;
165 memset(&context, 0, sizeof(context)); 165 memset(&context, 0, sizeof(context));
166 EXPECT_EQ(0, g_protocol->url_open(&context, key.c_str(), 0)); 166 EXPECT_EQ(0, g_protocol->url_open(&context, key.c_str(), 0));
167 glue->RemoveDataSource(data_source); 167 glue->RemoveDataSource(data_source);
168 EXPECT_FALSE(deleted); 168 EXPECT_FALSE(deleted);
169 169
170 // Writing should always fail. 170 // Writing should always fail.
(...skipping 26 matching lines...) Expand all
197 EXPECT_TRUE(deleted); 197 EXPECT_TRUE(deleted);
198 } 198 }
199 199
200 TEST(FFmpegGlueTest, Seeking) { 200 TEST(FFmpegGlueTest, Seeking) {
201 // Prepare testing data. 201 // Prepare testing data.
202 media::FFmpegGlue* glue = media::FFmpegGlue::get(); 202 media::FFmpegGlue* glue = media::FFmpegGlue::get();
203 const int64 kSize = 32; 203 const int64 kSize = 32;
204 204
205 // Create our data source and add them to the glue layer. 205 // Create our data source and add them to the glue layer.
206 bool deleted = false; 206 bool deleted = false;
207 media::MockFilterConfig config; 207 media::old_mocks::MockFilterConfig config;
208 config.media_total_bytes = kSize; 208 config.media_total_bytes = kSize;
209 scoped_refptr<media::MockDataSource> data_source 209 scoped_refptr<media::old_mocks::MockDataSource> data_source
210 = new media::MockDataSource(&config, &deleted); 210 = new media::old_mocks::MockDataSource(&config, &deleted);
211 std::string key = glue->AddDataSource(data_source); 211 std::string key = glue->AddDataSource(data_source);
212 212
213 // Open our data source and then remove it from the glue layer. 213 // Open our data source and then remove it from the glue layer.
214 URLContext context; 214 URLContext context;
215 memset(&context, 0, sizeof(context)); 215 memset(&context, 0, sizeof(context));
216 EXPECT_EQ(0, g_protocol->url_open(&context, key.c_str(), 0)); 216 EXPECT_EQ(0, g_protocol->url_open(&context, key.c_str(), 0));
217 glue->RemoveDataSource(data_source); 217 glue->RemoveDataSource(data_source);
218 EXPECT_FALSE(deleted); 218 EXPECT_FALSE(deleted);
219 219
220 // Test SEEK_SET operations. 220 // Test SEEK_SET operations.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 TEST(FFmpegGlueTest, Destructor) { 286 TEST(FFmpegGlueTest, Destructor) {
287 // Prepare testing data. 287 // Prepare testing data.
288 media::FFmpegGlue* glue = media::FFmpegGlue::get(); 288 media::FFmpegGlue* glue = media::FFmpegGlue::get();
289 289
290 // We use a static bool since ~FFmpegGlue() will set it to true sometime 290 // We use a static bool since ~FFmpegGlue() will set it to true sometime
291 // after this function exits. 291 // after this function exits.
292 static bool deleted = false; 292 static bool deleted = false;
293 293
294 // Create our data source and add them to the glue layer. 294 // Create our data source and add them to the glue layer.
295 media::MockFilterConfig config; 295 media::old_mocks::MockFilterConfig config;
296 scoped_refptr<media::MockDataSource> data_source 296 scoped_refptr<media::old_mocks::MockDataSource> data_source
297 = new media::MockDataSource(&config, &deleted); 297 = new media::old_mocks::MockDataSource(&config, &deleted);
298 std::string key = glue->AddDataSource(data_source); 298 std::string key = glue->AddDataSource(data_source);
299 299
300 // Remove our own reference. 300 // Remove our own reference.
301 data_source = NULL; 301 data_source = NULL;
302 EXPECT_FALSE(deleted); 302 EXPECT_FALSE(deleted);
303 303
304 // ~FFmpegGlue() will be called when this unit test finishes execution. By 304 // ~FFmpegGlue() will be called when this unit test finishes execution. By
305 // leaving something inside FFmpegGlue's map we get to test our cleanup code. 305 // leaving something inside FFmpegGlue's map we get to test our cleanup code.
306 // 306 //
307 // MockDataSource will be holding onto a bad MockFilterConfig pointer at this 307 // MockDataSource will be holding onto a bad MockFilterConfig pointer at this
308 // point but since no one is calling it everything will be ok. 308 // point but since no one is calling it everything will be ok.
309 } 309 }
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698