Index: media/base/android/mock_android_overlay.h |
diff --git a/media/base/android/mock_android_overlay.h b/media/base/android/mock_android_overlay.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2ac593bb88cc4e1f83deb22995b3d9c43015e9ca |
--- /dev/null |
+++ b/media/base/android/mock_android_overlay.h |
@@ -0,0 +1,47 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ |
DaleCurtis
2017/04/20 19:10:42
Hmm, seems like this should be in media/gpu/androi
liberato (no reviews please)
2017/04/20 22:01:38
seems more generally useful than that. i kept it
|
+#define MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ |
+ |
+#include "media/base/android/android_overlay.h" |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+ |
+namespace media { |
+ |
+// AndroidOverlay implementation that supports weak ptrs. |
+class MockAndroidOverlay : public ::testing::NiceMock<AndroidOverlay> { |
DaleCurtis
2017/04/20 19:10:42
Not StrictMock?
liberato (no reviews please)
2017/04/20 22:01:38
good point. i'll try it and see if anything fails
|
+ public: |
+ MockAndroidOverlay(); |
+ ~MockAndroidOverlay() override; |
+ |
+ MOCK_METHOD1(ScheduleLayout, void(const gfx::Rect&)); |
+ MOCK_CONST_METHOD0(GetJavaSurface, base::android::JavaRef<jobject>&()); |
+ |
+ // Set |config_|. Sometimes, it's convenient to do this after construction, |
+ // especially if one must create the overlay before the factory provides it |
+ // via CreateOverlay. That's helpful to set test expectations. |
+ void SetConfig(const Config& config); |
+ |
+ // Send callbacks. |
+ void OnOverlayReady(); |
+ void OnOverlayFailed(); |
+ void OnSurfaceDestroyed(); |
+ |
+ base::WeakPtr<MockAndroidOverlay> GetWeakPtr() { |
DaleCurtis
2017/04/20 19:10:42
Vending of WeakPtrs externally is generally a very
liberato (no reviews please)
2017/04/20 22:01:38
that's very hard to do, since they're always uniqu
|
+ return weak_factory_.GetWeakPtr(); |
+ } |
+ |
+ private: |
+ // Initial configuration, mostly for callbacks. |
+ Config config_; |
+ |
+ base::WeakPtrFactory<MockAndroidOverlay> weak_factory_; |
+}; |
DaleCurtis
2017/04/20 19:10:42
DISALLOW_COPY_AND_ASSIGN.
liberato (no reviews please)
2017/04/20 22:01:38
Done.
|
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ |