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

Unified Diff: media/base/android/mock_android_overlay.h

Issue 2813303003: Add AndroidVideoSurfaceChooser to manage overlays. (Closed)
Patch Set: from ps11 Created 3 years, 8 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
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..6543e7b68d44844cf8cc7b74485ee1fb0814a043
--- /dev/null
+++ b/media/base/android/mock_android_overlay.h
@@ -0,0 +1,68 @@
+// 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_
+#define MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_
+
+#include "media/base/android/android_overlay.h"
+
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "media/base/android/test_destruction_observable.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace media {
+
+// AndroidOverlay implementation that supports weak ptrs.
+class MockAndroidOverlay : public ::testing::StrictMock<AndroidOverlay>,
DaleCurtis 2017/04/27 18:57:37 No ::
liberato (no reviews please) 2017/04/27 20:05:02 Done.
+ public DestructionObservable {
+ 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);
+
+ // Set of callbacks that we provide to control the overlay once you've handed
+ // off ownership of it. Will return false if the overlay has been destroyed.
+ using ControlCallback = base::Callback<bool()>;
DaleCurtis 2017/04/27 18:57:37 base::OnceCallback or RepeatingCallback ?
liberato (no reviews please) 2017/04/27 20:05:02 Done.
+ struct Callbacks {
+ Callbacks();
+ Callbacks(const Callbacks&);
+ ~Callbacks();
+
+ ControlCallback OverlayReady;
+ ControlCallback OverlayFailed;
+ ControlCallback SurfaceDestroyed;
+ };
+
+ // Return callbacks that can be used to control the overlay.
+ Callbacks GetCallbacks();
+
+ private:
+ // Trampoline to promote |wp| and call |cb|, or return false.
+ static bool CallbackTrampoline(void (MockAndroidOverlay::*cb)(),
DaleCurtis 2017/04/27 18:57:37 Use a base callback signature?
liberato (no reviews please) 2017/04/27 20:05:02 ? anyway, doesn't matter. ended up deleting Call
+ base::WeakPtr<MockAndroidOverlay> wp);
+
+ // Send callbacks.
+ void OnOverlayReady();
+ void OnOverlayFailed();
+ void OnSurfaceDestroyed();
+
+ // Initial configuration, mostly for callbacks.
+ Config config_;
+
+ base::WeakPtrFactory<MockAndroidOverlay> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockAndroidOverlay);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_

Powered by Google App Engine
This is Rietveld 408576698