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. | |
watk
2017/05/02 21:00:00
The weak ptr comment could use clarification. It's
| |
18 class MockAndroidOverlay : public testing::StrictMock<AndroidOverlay>, | |
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::RepeatingCallback<void()>; | |
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 // Send callbacks. | |
50 void OnOverlayReady(); | |
51 void OnOverlayFailed(); | |
52 void OnSurfaceDestroyed(); | |
53 | |
54 // Initial configuration, mostly for callbacks. | |
55 Config config_; | |
56 | |
57 base::WeakPtrFactory<MockAndroidOverlay> weak_factory_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(MockAndroidOverlay); | |
60 }; | |
61 | |
62 } // namespace media | |
63 | |
64 #endif // MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ | |
OLD | NEW |