OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ | |
6 #define MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ | |
7 | |
8 #include "media/base/android/android_overlay.h" | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "media/base/android/test_destruction_observable.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | |
14 | |
15 namespace media { | |
16 | |
17 // AndroidOverlay implementation that supports weak ptrs. | |
18 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.
| |
19 public DestructionObservable { | |
20 public: | |
21 MockAndroidOverlay(); | |
22 ~MockAndroidOverlay() override; | |
23 | |
24 MOCK_METHOD1(ScheduleLayout, void(const gfx::Rect&)); | |
25 MOCK_CONST_METHOD0(GetJavaSurface, base::android::JavaRef<jobject>&()); | |
26 | |
27 // Set |config_|. Sometimes, it's convenient to do this after construction, | |
28 // especially if one must create the overlay before the factory provides it | |
29 // via CreateOverlay. That's helpful to set test expectations. | |
30 void SetConfig(const Config& config); | |
31 | |
32 // Set of callbacks that we provide to control the overlay once you've handed | |
33 // off ownership of it. Will return false if the overlay has been destroyed. | |
34 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.
| |
35 struct Callbacks { | |
36 Callbacks(); | |
37 Callbacks(const Callbacks&); | |
38 ~Callbacks(); | |
39 | |
40 ControlCallback OverlayReady; | |
41 ControlCallback OverlayFailed; | |
42 ControlCallback SurfaceDestroyed; | |
43 }; | |
44 | |
45 // Return callbacks that can be used to control the overlay. | |
46 Callbacks GetCallbacks(); | |
47 | |
48 private: | |
49 // Trampoline to promote |wp| and call |cb|, or return false. | |
50 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
| |
51 base::WeakPtr<MockAndroidOverlay> wp); | |
52 | |
53 // Send callbacks. | |
54 void OnOverlayReady(); | |
55 void OnOverlayFailed(); | |
56 void OnSurfaceDestroyed(); | |
57 | |
58 // Initial configuration, mostly for callbacks. | |
59 Config config_; | |
60 | |
61 base::WeakPtrFactory<MockAndroidOverlay> weak_factory_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(MockAndroidOverlay); | |
64 }; | |
65 | |
66 } // namespace media | |
67 | |
68 #endif // MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ | |
OLD | NEW |