Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f723cfc

Browse files
committed
WIP trying and failing to test this
1 parent e4ddb31 commit f723cfc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package io.flutter.plugin.platform;
22

3+
import static org.junit.Assert.assertTrue;
34
import static org.mockito.Mockito.mock;
45
import static org.mockito.Mockito.when;
56

67
import android.app.Activity;
8+
import android.content.ClipboardManager;
79
import android.view.View;
810
import android.view.Window;
911
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
1012
import org.junit.Test;
1113
import org.junit.runner.RunWith;
1214
import org.robolectric.RobolectricTestRunner;
15+
import org.robolectric.RuntimeEnvironment;
1316
import org.robolectric.annotation.Config;
1417

1518
@Config(manifest = Config.NONE)
@@ -32,4 +35,24 @@ public void itIgnoresNewHapticEventsOnOldAndroidPlatforms() {
3235
// SELECTION_CLICK haptic response is only available on "LOLLIPOP" (21) and later.
3336
platformPlugin.vibrateHapticFeedback(PlatformChannel.HapticFeedbackType.SELECTION_CLICK);
3437
}
38+
39+
@Test
40+
public void platformPlugin_hasStrings() {
41+
View fakeDecorView = mock(View.class);
42+
Window fakeWindow = mock(Window.class);
43+
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
44+
Activity fakeActivity = mock(Activity.class);
45+
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
46+
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
47+
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
48+
49+
ClipboardManager clipboardManager =
50+
RuntimeEnvironment.application.getSystemService(ClipboardManager.class);
51+
clipboardManager.setText("iamastring");
52+
53+
// TODO(justinmc): Can't do this because mPlatformMessageHandler is private.
54+
// How can I send a message to the platform plugin?
55+
//boolean hasStrings = platformPlugin.mPlatformMessageHandler.clipboardHasStrings();
56+
//assertTrue(hasStrings);
57+
}
3558
}

0 commit comments

Comments
 (0)