Chromium Code Reviews| 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_ | |
|
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
| |
| 6 #define MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ | |
| 7 | |
| 8 #include "media/base/android/android_overlay.h" | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "testing/gmock/include/gmock/gmock.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 // AndroidOverlay implementation that supports weak ptrs. | |
| 16 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
| |
| 17 public: | |
| 18 MockAndroidOverlay(); | |
| 19 ~MockAndroidOverlay() override; | |
| 20 | |
| 21 MOCK_METHOD1(ScheduleLayout, void(const gfx::Rect&)); | |
| 22 MOCK_CONST_METHOD0(GetJavaSurface, base::android::JavaRef<jobject>&()); | |
| 23 | |
| 24 // Set |config_|. Sometimes, it's convenient to do this after construction, | |
| 25 // especially if one must create the overlay before the factory provides it | |
| 26 // via CreateOverlay. That's helpful to set test expectations. | |
| 27 void SetConfig(const Config& config); | |
| 28 | |
| 29 // Send callbacks. | |
| 30 void OnOverlayReady(); | |
| 31 void OnOverlayFailed(); | |
| 32 void OnSurfaceDestroyed(); | |
| 33 | |
| 34 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
| |
| 35 return weak_factory_.GetWeakPtr(); | |
| 36 } | |
| 37 | |
| 38 private: | |
| 39 // Initial configuration, mostly for callbacks. | |
| 40 Config config_; | |
| 41 | |
| 42 base::WeakPtrFactory<MockAndroidOverlay> weak_factory_; | |
| 43 }; | |
|
DaleCurtis
2017/04/20 19:10:42
DISALLOW_COPY_AND_ASSIGN.
liberato (no reviews please)
2017/04/20 22:01:38
Done.
| |
| 44 | |
| 45 } // namespace media | |
| 46 | |
| 47 #endif // MEDIA_BASE_ANDROID_MOCK_ANDROID_OVERLAY_H_ | |
| OLD | NEW |