diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/gtest/MockMediaResource.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/gtest/MockMediaResource.h')
-rw-r--r-- | dom/media/gtest/MockMediaResource.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/dom/media/gtest/MockMediaResource.h b/dom/media/gtest/MockMediaResource.h new file mode 100644 index 000000000..129ba1b72 --- /dev/null +++ b/dom/media/gtest/MockMediaResource.h @@ -0,0 +1,83 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef MOCK_MEDIA_RESOURCE_H_ +#define MOCK_MEDIA_RESOURCE_H_ + +#include "MediaResource.h" +#include "nsTArray.h" +#include "mozilla/Atomics.h" + +namespace mozilla +{ + +class MockMediaResource : public MediaResource +{ +public: + explicit MockMediaResource(const char* aFileName, const nsACString& aMimeType = NS_LITERAL_CSTRING("video/mp4")); + nsIURI* URI() const override { return nullptr; } + nsresult Close() override { return NS_OK; } + void Suspend(bool aCloseImmediately) override {} + void Resume() override {} + already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override + { + return nullptr; + } + bool CanClone() override { return false; } + already_AddRefed<MediaResource> CloneData(MediaResourceCallback*) + override + { + return nullptr; + } + void SetReadMode(MediaCacheStream::ReadMode aMode) override {} + void SetPlaybackRate(uint32_t aBytesPerSecond) override {} + nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, + uint32_t* aBytes) override; + int64_t Tell() override { return 0; } + void Pin() override {} + void Unpin() override {} + double GetDownloadRate(bool* aIsReliable) override { return 0; } + int64_t GetLength() override; + int64_t GetNextCachedData(int64_t aOffset) override; + int64_t GetCachedDataEnd(int64_t aOffset) override; + bool IsDataCachedToEndOfResource(int64_t aOffset) override + { + return false; + } + bool IsSuspendedByCache() override { return false; } + bool IsSuspended() override { return false; } + nsresult ReadFromCache(char* aBuffer, int64_t aOffset, + uint32_t aCount) override + { + uint32_t bytesRead = 0; + nsresult rv = ReadAt(aOffset, aBuffer, aCount, &bytesRead); + NS_ENSURE_SUCCESS(rv, rv); + return bytesRead == aCount ? NS_OK : NS_ERROR_FAILURE; + } + + bool IsTransportSeekable() override { return true; } + nsresult Open(nsIStreamListener** aStreamListener) override; + nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override; + const nsCString& GetContentType() const override + { + return mContentType; + } + + void MockClearBufferedRanges(); + void MockAddBufferedRange(int64_t aStart, int64_t aEnd); + +protected: + virtual ~MockMediaResource(); + +private: + FILE* mFileHandle; + const char* mFileName; + MediaByteRangeSet mRanges; + Atomic<int> mEntry; + const nsCString mContentType; +}; + +} // namespace mozilla + +#endif |