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

Unified Diff: media/base/mock_media_filters.h

Issue 28165: Checking in media::FFmpegGlue and some common FFmpeg code. (Closed)
Patch Set: mime type stuff Created 11 years, 10 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/DEPS ('k') | media/build/media.vcproj » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/mock_media_filters.h
diff --git a/media/base/mock_media_filters.h b/media/base/mock_media_filters.h
index 079c681a69b0ff98a3fd46d1c91f54e09b7472ac..0620eff78b7595473a091100bb79ffd859ce7b23 100644
--- a/media/base/mock_media_filters.h
+++ b/media/base/mock_media_filters.h
@@ -37,6 +37,7 @@ enum MockDataSourceBehavior {
struct MockFilterConfig {
MockFilterConfig()
: data_source_behavior(MOCK_DATA_SOURCE_NORMAL_INIT),
+ data_source_value('!'),
has_video(true),
video_width(1280u),
video_height(720u),
@@ -52,6 +53,7 @@ struct MockFilterConfig {
}
MockDataSourceBehavior data_source_behavior;
+ char data_source_value;
bool has_video;
size_t video_width;
size_t video_height;
@@ -76,7 +78,16 @@ class MockDataSource : public DataSource {
explicit MockDataSource(const MockFilterConfig* config)
: config_(config),
- position_(0) {
+ position_(0),
+ deleted_(NULL) {
+ }
+
+ MockDataSource(const MockFilterConfig* config, bool* deleted)
+ : config_(config),
+ position_(0),
+ deleted_(deleted) {
+ EXPECT_TRUE(deleted);
+ EXPECT_FALSE(*deleted);
}
// Implementation of MediaFilter.
@@ -121,7 +132,7 @@ class MockDataSource : public DataSource {
if (size < read) {
read = size;
}
- memset(data, 0, read);
+ memset(data, config_->data_source_value, read);
return read;
}
@@ -131,8 +142,6 @@ class MockDataSource : public DataSource {
}
virtual bool SetPosition(int64 position) {
- EXPECT_GE(position, 0u);
- EXPECT_LE(position, config_->media_total_bytes);
if (position < 0u || position > config_->media_total_bytes) {
return false;
}
@@ -141,12 +150,22 @@ class MockDataSource : public DataSource {
}
virtual bool GetSize(int64* size_out) {
- *size_out = config_->media_total_bytes;
+ if (config_->media_total_bytes >= 0) {
+ *size_out = config_->media_total_bytes;
+ return true;
+ }
return false;
}
+ // Simple position getter for unit testing.
+ int64 position() const { return position_; }
+
private:
- virtual ~MockDataSource() {}
+ virtual ~MockDataSource() {
+ if (deleted_) {
+ *deleted_ = true;
+ }
+ }
void TaskBehavior() {
switch (config_->data_source_behavior) {
@@ -166,6 +185,10 @@ class MockDataSource : public DataSource {
int64 position_;
MediaFormat media_format_;
+ // Set to true inside the destructor. Used in FFmpegGlue unit tests for
+ // testing proper reference counting.
+ bool* deleted_;
+
DISALLOW_COPY_AND_ASSIGN(MockDataSource);
};
« no previous file with comments | « media/DEPS ('k') | media/build/media.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698