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

Side by Side Diff: media/base/android/mock_android_overlay.h

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

Powered by Google App Engine
This is Rietveld 408576698