@Test public void testOnStop() { ShadowActivity shadowActivity = Shadows.shadowOf(activity); activity.onStop(); assertFalse(shadowActivity.isFinishing()); }
@Test public void testRefreshBluetooth() { ShadowActivity shadowActivity = Shadows.shadowOf(activity); activity.findViewById(R.id.refresh_bluetooth).performClick(); assertEquals( "Unexpected toast text", shadowActivity.getString(R.string.scan_for_devices), ShadowToast.getTextOfLatestToast()); }
@Test public void testBluetoothSelected_nochange() { ShadowActivity shadowActivity = Shadows.shadowOf(activity); activity.selectedItemTV.setText("No Device Selected!"); activity.findViewById(R.id.done_selecting).performClick(); assertEquals( "Unexpected toast text", shadowActivity.getString(R.string.no_change_to_device), ShadowToast.getTextOfLatestToast()); assertTrue("finish() was not called", shadowActivity.isFinishing()); }
@Test public void testUIElements() { Button button; TextView textView; ListView listView; textView = (TextView) activity.findViewById(R.id.selectdevice); assertNotNull("TextView is null", textView); listView = (ListView) activity.findViewById(R.id.bluetooth_list); assertNotNull("ListView is null", listView); textView = (TextView) activity.findViewById(R.id.selected_device_value); assertNotNull("TextView is null", textView); button = (Button) activity.findViewById(R.id.refresh_bluetooth); assertNotNull("Button is null", button); button = (Button) activity.findViewById(R.id.done_selecting); assertNotNull("Button is null", button); }