|
45 | 45 |
|
46 | 46 | namespace flutter {
|
47 | 47 | namespace testing {
|
48 |
| - |
49 |
| -using ::testing::_; |
50 |
| -using ::testing::Return; |
51 |
| - |
52 | 48 | namespace {
|
53 | 49 | class MockPlatformViewDelegate : public PlatformView::Delegate {
|
54 | 50 | MOCK_METHOD1(OnPlatformViewCreated, void(std::unique_ptr<Surface> surface));
|
@@ -123,27 +119,6 @@ class MockPlatformView : public PlatformView {
|
123 | 119 | MockPlatformView(MockPlatformViewDelegate& delegate, TaskRunners task_runners)
|
124 | 120 | : PlatformView(delegate, task_runners) {}
|
125 | 121 | MOCK_METHOD0(CreateRenderingSurface, std::unique_ptr<Surface>());
|
126 |
| - MOCK_CONST_METHOD0(GetPlatformMessageHandler, |
127 |
| - std::shared_ptr<PlatformMessageHandler>()); |
128 |
| -}; |
129 |
| - |
130 |
| -class MockPlatformMessageHandler : public PlatformMessageHandler { |
131 |
| - public: |
132 |
| - MOCK_METHOD1(HandlePlatformMessage, |
133 |
| - void(std::unique_ptr<PlatformMessage> message)); |
134 |
| - MOCK_METHOD2(InvokePlatformMessageResponseCallback, |
135 |
| - void(int response_id, std::unique_ptr<fml::Mapping> mapping)); |
136 |
| - MOCK_METHOD1(InvokePlatformMessageEmptyResponseCallback, |
137 |
| - void(int response_id)); |
138 |
| -}; |
139 |
| - |
140 |
| -class MockPlatformMessageResponse : public PlatformMessageResponse { |
141 |
| - public: |
142 |
| - static fml::RefPtr<MockPlatformMessageResponse> Create() { |
143 |
| - return fml::AdoptRef(new MockPlatformMessageResponse()); |
144 |
| - } |
145 |
| - MOCK_METHOD1(Complete, void(std::unique_ptr<fml::Mapping> data)); |
146 |
| - MOCK_METHOD0(CompleteEmpty, void()); |
147 | 122 | };
|
148 | 123 | } // namespace
|
149 | 124 |
|
@@ -3187,52 +3162,7 @@ TEST_F(ShellTest, UIWorkAfterOnPlatformViewDestroyed) {
|
3187 | 3162 | shell->GetTaskRunners().GetUITaskRunner(),
|
3188 | 3163 | [&ui_flush_latch]() { ui_flush_latch.Signal(); });
|
3189 | 3164 | ui_flush_latch.Wait();
|
3190 |
| - DestroyShell(std::move(shell)); |
3191 |
| -} |
3192 | 3165 |
|
3193 |
| -TEST_F(ShellTest, UsesPlatformMessageHandler) { |
3194 |
| - TaskRunners task_runners = GetTaskRunnersForFixture(); |
3195 |
| - auto settings = CreateSettingsForFixture(); |
3196 |
| - MockPlatformViewDelegate platform_view_delegate; |
3197 |
| - auto platform_message_handler = |
3198 |
| - std::make_shared<MockPlatformMessageHandler>(); |
3199 |
| - int message_id = 1; |
3200 |
| - EXPECT_CALL(*platform_message_handler, HandlePlatformMessage(_)); |
3201 |
| - EXPECT_CALL(*platform_message_handler, |
3202 |
| - InvokePlatformMessageEmptyResponseCallback(message_id)); |
3203 |
| - Shell::CreateCallback<PlatformView> platform_view_create_callback = |
3204 |
| - [&platform_view_delegate, task_runners, |
3205 |
| - platform_message_handler](flutter::Shell& shell) { |
3206 |
| - auto result = std::make_unique<MockPlatformView>(platform_view_delegate, |
3207 |
| - task_runners); |
3208 |
| - EXPECT_CALL(*result, GetPlatformMessageHandler()) |
3209 |
| - .WillOnce(Return(platform_message_handler)); |
3210 |
| - return result; |
3211 |
| - }; |
3212 |
| - auto shell = CreateShell( |
3213 |
| - /*settings=*/std::move(settings), |
3214 |
| - /*task_runners=*/task_runners, |
3215 |
| - /*simulate_vsync=*/false, |
3216 |
| - /*shell_test_external_view_embedder=*/nullptr, |
3217 |
| - /*is_gpu_disabled=*/false, |
3218 |
| - /*rendering_backend=*/ |
3219 |
| - ShellTestPlatformView::BackendType::kDefaultBackend, |
3220 |
| - /*platform_view_create_callback=*/platform_view_create_callback); |
3221 |
| - |
3222 |
| - EXPECT_EQ(platform_message_handler, shell->GetPlatformMessageHandler()); |
3223 |
| - PostSync(task_runners.GetUITaskRunner(), [&shell]() { |
3224 |
| - size_t data_size = 4; |
3225 |
| - fml::MallocMapping bytes = |
3226 |
| - fml::MallocMapping(static_cast<uint8_t*>(malloc(data_size)), data_size); |
3227 |
| - fml::RefPtr<MockPlatformMessageResponse> response = |
3228 |
| - MockPlatformMessageResponse::Create(); |
3229 |
| - auto message = std::make_unique<PlatformMessage>( |
3230 |
| - /*channel=*/"foo", /*data=*/std::move(bytes), /*response=*/response); |
3231 |
| - (static_cast<Engine::Delegate*>(shell.get())) |
3232 |
| - ->OnEngineHandlePlatformMessage(std::move(message)); |
3233 |
| - }); |
3234 |
| - shell->GetPlatformMessageHandler() |
3235 |
| - ->InvokePlatformMessageEmptyResponseCallback(message_id); |
3236 | 3166 | DestroyShell(std::move(shell));
|
3237 | 3167 | }
|
3238 | 3168 |
|
|
0 commit comments