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

Side by Side Diff: media/base/mock_ffmpeg.h

Issue 149423: Converted remaining tests to use gmock and deleted all old mocking code. (Closed)
Patch Set: Fix again Created 11 years, 5 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 | « no previous file | media/base/mock_ffmpeg.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef MEDIA_BASE_MOCK_FFMPEG_H_ 5 #ifndef MEDIA_BASE_MOCK_FFMPEG_H_
6 #define MEDIA_BASE_MOCK_FFMPEG_H_ 6 #define MEDIA_BASE_MOCK_FFMPEG_H_
7 7
8 // TODO(scherkus): See if we can remove ffmpeg_common from this file. 8 // TODO(scherkus): See if we can remove ffmpeg_common from this file.
9 #include "media/filters/ffmpeg_common.h" 9 #include "media/filters/ffmpeg_common.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 11
12 namespace media { 12 namespace media {
13 13
14 class MockFFmpeg { 14 class MockFFmpeg {
15 public: 15 public:
16 MockFFmpeg(); 16 MockFFmpeg();
17 virtual ~MockFFmpeg(); 17 virtual ~MockFFmpeg();
18 18
19 MOCK_METHOD0(AVCodecInit, void());
20 MOCK_METHOD1(AVRegisterProtocol, int(URLProtocol* protocol));
21 MOCK_METHOD0(AVRegisterAll, void());
22
19 MOCK_METHOD1(AVCodecFindDecoder, AVCodec*(enum CodecID id)); 23 MOCK_METHOD1(AVCodecFindDecoder, AVCodec*(enum CodecID id));
20 MOCK_METHOD2(AVCodecOpen, int(AVCodecContext* avctx, AVCodec* codec)); 24 MOCK_METHOD2(AVCodecOpen, int(AVCodecContext* avctx, AVCodec* codec));
21 MOCK_METHOD1(AVCodecClose, int(AVCodecContext* avctx)); 25 MOCK_METHOD1(AVCodecClose, int(AVCodecContext* avctx));
22 MOCK_METHOD2(AVCodecThreadInit, int(AVCodecContext* avctx, int threads)); 26 MOCK_METHOD2(AVCodecThreadInit, int(AVCodecContext* avctx, int threads));
23 MOCK_METHOD1(AVCodecFlushBuffers, void(AVCodecContext* avctx)); 27 MOCK_METHOD1(AVCodecFlushBuffers, void(AVCodecContext* avctx));
24 MOCK_METHOD0(AVCodecAllocFrame, AVFrame*()); 28 MOCK_METHOD0(AVCodecAllocFrame, AVFrame*());
25 MOCK_METHOD4(AVCodecDecodeVideo2, 29 MOCK_METHOD4(AVCodecDecodeVideo2,
26 int(AVCodecContext* avctx, AVFrame* picture, 30 int(AVCodecContext* avctx, AVFrame* picture,
27 int* got_picture_ptr, AVPacket* avpkt)); 31 int* got_picture_ptr, AVPacket* avpkt));
28 32
(...skipping 15 matching lines...) Expand all
44 MOCK_METHOD1(AVFreePacket, void(AVPacket* packet)); 48 MOCK_METHOD1(AVFreePacket, void(AVPacket* packet));
45 MOCK_METHOD1(AVFree, void(void* ptr)); 49 MOCK_METHOD1(AVFree, void(void* ptr));
46 50
47 // Used for verifying check points during tests. 51 // Used for verifying check points during tests.
48 MOCK_METHOD1(CheckPoint, void(int id)); 52 MOCK_METHOD1(CheckPoint, void(int id));
49 53
50 // Setter/getter for the global instance of MockFFmpeg. 54 // Setter/getter for the global instance of MockFFmpeg.
51 static void set(MockFFmpeg* instance); 55 static void set(MockFFmpeg* instance);
52 static MockFFmpeg* get(); 56 static MockFFmpeg* get();
53 57
58 // Returns the URLProtocol registered by the FFmpegGlue singleton.
59 static URLProtocol* protocol();
60
54 // AVPacket destructor for packets allocated by av_new_packet(). 61 // AVPacket destructor for packets allocated by av_new_packet().
55 static void DestructPacket(AVPacket* packet); 62 static void DestructPacket(AVPacket* packet);
56 63
57 // Modifies the number of outstanding packets. 64 // Modifies the number of outstanding packets.
58 void inc_outstanding_packets(); 65 void inc_outstanding_packets();
59 void dec_outstanding_packets(); 66 void dec_outstanding_packets();
60 67
61 private: 68 private:
62 static MockFFmpeg* instance_; 69 static MockFFmpeg* instance_;
70 static URLProtocol* protocol_;
63 71
64 // Tracks the number of packets allocated by calls to av_read_frame() and 72 // Tracks the number of packets allocated by calls to av_read_frame() and
65 // av_free_packet(). We crash the unit test if this is not zero at time of 73 // av_free_packet(). We crash the unit test if this is not zero at time of
66 // destruction. 74 // destruction.
67 int outstanding_packets_; 75 int outstanding_packets_;
68 }; 76 };
69 77
70 // Used for simulating av_read_frame(). 78 // Used for simulating av_read_frame().
71 ACTION_P3(CreatePacket, stream_index, data, size) { 79 ACTION_P3(CreatePacket, stream_index, data, size) {
72 // Confirm we're dealing with AVPacket so we can safely const_cast<>. 80 // Confirm we're dealing with AVPacket so we can safely const_cast<>.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 arg0->destruct(arg0); 114 arg0->destruct(arg0);
107 } 115 }
108 116
109 // Decrement number of packets allocated. 117 // Decrement number of packets allocated.
110 MockFFmpeg::get()->dec_outstanding_packets(); 118 MockFFmpeg::get()->dec_outstanding_packets();
111 } 119 }
112 120
113 } // namespace media 121 } // namespace media
114 122
115 #endif // MEDIA_BASE_MOCK_FFMPEG_H_ 123 #endif // MEDIA_BASE_MOCK_FFMPEG_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/mock_ffmpeg.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698