|
| 1 | +#include <memory> |
| 2 | +#include "flutter/shell/platform/android/android_shell_holder.h" |
| 3 | +#include "gmock/gmock.h" |
| 4 | +#include "gtest/gtest.h" |
| 5 | + |
| 6 | +namespace flutter { |
| 7 | +namespace testing { |
| 8 | +namespace { |
| 9 | +class MockPlatformViewAndroidJNI : public PlatformViewAndroidJNI { |
| 10 | + MOCK_METHOD2(FlutterViewHandlePlatformMessage, |
| 11 | + void(std::unique_ptr<flutter::PlatformMessage> message, |
| 12 | + int responseId)); |
| 13 | + MOCK_METHOD2(FlutterViewHandlePlatformMessageResponse, |
| 14 | + void(int responseId, std::unique_ptr<fml::Mapping> data)); |
| 15 | + MOCK_METHOD3(FlutterViewUpdateSemantics, |
| 16 | + void(std::vector<uint8_t> buffer, |
| 17 | + std::vector<std::string> strings, |
| 18 | + std::vector<std::vector<uint8_t>> string_attribute_args)); |
| 19 | + MOCK_METHOD2(FlutterViewUpdateCustomAccessibilityActions, |
| 20 | + void(std::vector<uint8_t> actions_buffer, |
| 21 | + std::vector<std::string> strings)); |
| 22 | + MOCK_METHOD0(FlutterViewOnFirstFrame, void()); |
| 23 | + MOCK_METHOD0(FlutterViewOnPreEngineRestart, void()); |
| 24 | + MOCK_METHOD2(SurfaceTextureAttachToGLContext, |
| 25 | + void(JavaLocalRef surface_texture, int textureId)); |
| 26 | + MOCK_METHOD1(SurfaceTextureUpdateTexImage, |
| 27 | + void(JavaLocalRef surface_texture)); |
| 28 | + MOCK_METHOD2(SurfaceTextureGetTransformMatrix, |
| 29 | + void(JavaLocalRef surface_texture, SkMatrix& transform)); |
| 30 | + MOCK_METHOD1(SurfaceTextureDetachFromGLContext, |
| 31 | + void(JavaLocalRef surface_texture)); |
| 32 | + MOCK_METHOD8(FlutterViewOnDisplayPlatformView, |
| 33 | + void(int view_id, |
| 34 | + int x, |
| 35 | + int y, |
| 36 | + int width, |
| 37 | + int height, |
| 38 | + int viewWidth, |
| 39 | + int viewHeight, |
| 40 | + MutatorsStack mutators_stack)); |
| 41 | + MOCK_METHOD5(FlutterViewDisplayOverlaySurface, |
| 42 | + void(int surface_id, int x, int y, int width, int height)); |
| 43 | + MOCK_METHOD0(FlutterViewBeginFrame, void()); |
| 44 | + MOCK_METHOD0(FlutterViewEndFrame, void()); |
| 45 | + MOCK_METHOD0(FlutterViewCreateOverlaySurface, |
| 46 | + std::unique_ptr<PlatformViewAndroidJNI::OverlayMetadata>()); |
| 47 | + MOCK_METHOD0(FlutterViewDestroyOverlaySurfaces, void()); |
| 48 | + MOCK_METHOD1(FlutterViewComputePlatformResolvedLocale, |
| 49 | + std::unique_ptr<std::vector<std::string>>( |
| 50 | + std::vector<std::string> supported_locales_data)); |
| 51 | + MOCK_METHOD0(GetDisplayRefreshRate, double()); |
| 52 | + MOCK_METHOD1(RequestDartDeferredLibrary, bool(int loading_unit_id)); |
| 53 | +}; |
| 54 | +} // namespace |
| 55 | + |
| 56 | +TEST(AndroidShellHolder, Create) { |
| 57 | + Settings settings; |
| 58 | + settings.enable_software_rendering = false; |
| 59 | + auto jni = std::make_shared<MockPlatformViewAndroidJNI>(); |
| 60 | + auto holder = std::make_unique<AndroidShellHolder>( |
| 61 | + settings, jni, /*is_background_view=*/false); |
| 62 | + EXPECT_NE(holder.get(), nullptr); |
| 63 | + EXPECT_TRUE(holder->IsValid()); |
| 64 | + EXPECT_NE(holder->GetPlatformView().get(), nullptr); |
| 65 | + auto window = |
| 66 | + fml::MakeRefCounted<AndroidNativeWindow>(nullptr, /*is_offscreen=*/true); |
| 67 | + holder->GetPlatformView()->NotifyCreated(window); |
| 68 | +} |
| 69 | +} // namespace testing |
| 70 | +} // namespace flutter |
0 commit comments