public void testOnSelect() throws Throwable { runTestOnUiThread( new Runnable() { @Override public void run() { ReactPicker spinner = getViewAtPath(0, 0); spinner.setSelection(2); } }); getInstrumentation().waitForIdleSync(); waitForBridgeAndUIIdle(); List<Integer> selections = mRecordingModule.getSelections(); assertEquals(1, selections.size()); assertEquals(2, (int) selections.get(0)); }
private void updateFirstSpinnerAndCheckLastSpinnerMatches( final int indexToSelect ) throws Throwable { // The last spinner has the same selected value as the first one. // Test that user selection is propagated correctly to JS, to setState, and to Spinners. runTestOnUiThread( new Runnable() { @Override public void run() { ReactPicker spinner = getViewAtPath(0, 0); spinner.setSelection(indexToSelect); } }); getInstrumentation().waitForIdleSync(); waitForBridgeAndUIIdle(); ReactPicker spinnerInSync = getViewAtPath(0, 3); assertEquals( "Picker selection was not updated correctly via setState.", indexToSelect, spinnerInSync.getSelectedItemPosition()); }
public void testUpdateSelectedItem() { ReactPicker spinner = getViewAtPath(0, 0); assertEquals(1, spinner.getSelectedItemPosition()); getTestModule().selectItem(2); waitForBridgeAndUIIdle(); getInstrumentation().waitForIdleSync(); assertEquals(2, spinner.getSelectedItemPosition()); }
public void testUpdateMode() { ReactPicker spinner = getViewAtPath(0, 1); assertEquals(Spinner.MODE_DROPDOWN, spinner.getMode()); getTestModule().setMode("dialog"); waitForBridgeAndUIIdle(); getInstrumentation().waitForIdleSync(); // changing the spinner mode in JS actually creates a new component on the native side, as // there's no way to change the mode once you have constructed a Spinner. ReactPicker newPicker = getViewAtPath(0, 1); assertTrue(spinner != newPicker); assertEquals(Spinner.MODE_DIALOG, newPicker.getMode()); }
public void testBasicProperties() { ReactPicker spinner = getViewAtPath(0, 0); SpinnerAdapter adapter = spinner.getAdapter(); assertEquals(Spinner.MODE_DIALOG, spinner.getMode()); assertEquals("prompt", spinner.getPrompt()); assertNotNull(adapter); assertEquals(3, adapter.getCount()); assertEquals("item1", ((TextView) adapter.getView(0, null, null)).getText()); assertEquals("item2", ((TextView) adapter.getView(1, null, null)).getText()); assertEquals("item3", ((TextView) adapter.getView(2, null, null)).getText()); assertEquals(1, spinner.getSelectedItemPosition()); // test colors assertEquals(Color.RED, ((TextView) adapter.getView(0, null, null)).getCurrentTextColor()); assertEquals(Color.GREEN, ((TextView) adapter.getView(1, null, null)).getCurrentTextColor()); assertEquals(Color.BLUE, ((TextView) adapter.getView(2, null, null)).getCurrentTextColor()); assertEquals( Color.RED, ((TextView) adapter.getDropDownView(0, null, null)).getCurrentTextColor()); assertEquals( Color.GREEN, ((TextView) adapter.getDropDownView(1, null, null)).getCurrentTextColor()); assertEquals( Color.BLUE, ((TextView) adapter.getDropDownView(2, null, null)).getCurrentTextColor()); getTestModule().setPrimaryColor("black"); waitForBridgeAndUIIdle(); assertEquals(Color.BLACK, ((TextView) adapter.getView(0, null, null)).getCurrentTextColor()); assertEquals(Color.BLACK, ((TextView) adapter.getView(1, null, null)).getCurrentTextColor()); assertEquals(Color.BLACK, ((TextView) adapter.getView(2, null, null)).getCurrentTextColor()); assertEquals( Color.RED, ((TextView) adapter.getDropDownView(0, null, null)).getCurrentTextColor()); assertEquals( Color.GREEN, ((TextView) adapter.getDropDownView(1, null, null)).getCurrentTextColor()); assertEquals( Color.BLUE, ((TextView) adapter.getDropDownView(2, null, null)).getCurrentTextColor()); }
public void testDropdownPicker() { ReactPicker spinner = getViewAtPath(0, 1); assertEquals(Spinner.MODE_DROPDOWN, spinner.getMode()); }
public void testDisabledPicker() { ReactPicker spinner = getViewAtPath(0, 2); assertFalse(spinner.isEnabled()); }