11package io .flutter .plugin .platform ;
22
3+ import static org .junit .Assert .assertTrue ;
34import static org .mockito .Mockito .mock ;
45import static org .mockito .Mockito .when ;
56
67import android .app .Activity ;
8+ import android .content .ClipboardManager ;
79import android .view .View ;
810import android .view .Window ;
911import io .flutter .embedding .engine .systemchannels .PlatformChannel ;
1012import org .junit .Test ;
1113import org .junit .runner .RunWith ;
1214import org .robolectric .RobolectricTestRunner ;
15+ import org .robolectric .RuntimeEnvironment ;
1316import 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