android.test.suitebuilder.annotation.Suppress Java Examples
The following examples show how to use
android.test.suitebuilder.annotation.Suppress.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestBeanAdvanced.java From bean-sdk-android with MIT License | 6 votes |
@Suppress public void testFastSerialMessages() throws Exception { int times = 100; final CountDownLatch testCompletionLatch = new CountDownLatch(times); Bean bean = discoverBean(); synchronousConnect(bean); for (int i = 0; i < times; i ++) { bean.readLed(new Callback<LedColor>() { @Override public void onResult(LedColor result) { testCompletionLatch.countDown(); } }); } testCompletionLatch.await(120, TimeUnit.SECONDS); synchronousDisconnect(bean); }
Example #2
Source File: TestFileContentProviderTest.java From android-test with Apache License 2.0 | 6 votes |
@Suppress public void testQueryFile() throws Exception { write("file1 contents", new File(hostedDirectory, "file1.txt"), Charsets.UTF_8); Cursor cursor = resolver.query( makeUri("file1.txt"), HostedFile.HostedFileColumn.getColumnNames(), "", EMPTY_ARRAY, ""); try { assertEquals(1, cursor.getCount()); int nameIndex = HostedFile.HostedFileColumn.NAME.getPosition(); int typeIndex = HostedFile.HostedFileColumn.TYPE.getPosition(); int sizeIndex = HostedFile.HostedFileColumn.SIZE.getPosition(); assertEquals("file1.txt", cursor.getString(nameIndex)); assertEquals( HostedFile.FileType.FILE, HostedFile.FileType.fromTypeCode(cursor.getString(typeIndex))); assertEquals("file1 contents".length(), cursor.getString(sizeIndex)); } finally { cursor.close(); } }
Example #3
Source File: TestFileContentProviderTest.java From android-test with Apache License 2.0 | 5 votes |
@Suppress public void testQueryDirectory() throws Exception { write("file1 contents", new File(hostedDirectory, "file1.txt"), Charsets.UTF_8); write("brown cow", new File(hostedDirectory, "file2.txt"), Charsets.UTF_8); new File(hostedDirectory, "subdir").mkdirs(); Cursor cursor = resolver.query( makeUri(""), HostedFile.HostedFileColumn.getColumnNames(), "", EMPTY_ARRAY, ""); List<String> listedFileNames = Lists.newArrayList(); try { assertEquals(2, cursor.getCount()); int nameIndex = HostedFile.HostedFileColumn.NAME.getPosition(); int typeIndex = HostedFile.HostedFileColumn.TYPE.getPosition(); while (cursor.moveToNext()) { listedFileNames.add(cursor.getString(nameIndex)); HostedFile.FileType expectedFileType = HostedFile.FileType.FILE; if (cursor.getString(nameIndex).equals("subdir")) { expectedFileType = HostedFile.FileType.DIRECTORY; } HostedFile.FileType actualType = HostedFile.FileType.fromTypeCode(cursor.getString(typeIndex)); assertEquals("Wrong file type: " + cursor, expectedFileType, actualType); } } finally { cursor.close(); } assertContents(listedFileNames, "file1.txt", "file2.txt", "subdir"); }
Example #4
Source File: CordovaResourceApiTest.java From crosswalk-cordova-android with Apache License 2.0 | 5 votes |
@Suppress public void testValidContentUri() throws IOException { Uri contentUri = createTestImageContentUri(); File localFile = resourceApi.mapUriToFile(contentUri); assertNotNull(localFile); performApiTest(contentUri, "image/jpeg", localFile, true, true); }
Example #5
Source File: ErrorUrlTest.java From crosswalk-cordova-android with Apache License 2.0 | 5 votes |
@Suppress public void testUrl() throws Throwable { sleep(); runTestOnUiThread(new Runnable() { public void run() { String good_url = "file:///android_asset/www/htmlnotfound/error.html"; String url = testView.getUrl(); assertNotNull(url); assertEquals(good_url, url); } }); }
Example #6
Source File: TestBeanAdvanced.java From bean-sdk-android with MIT License | 4 votes |
@Suppress public void testBeanSketchUpload() throws Exception { final Bean bean = discoverBean(); synchronousConnect(bean); String hwVersion = getDeviceInformation(bean).hardwareVersion(); String hexPath = null; for (String filename : filesInAssetDir(getContext(), "bean_fw_advanced_callbacks")) { if (FilenameUtils.getExtension(filename).equals("hex")) { String[] pieces = FilenameUtils.getBaseName(filename).split("_"); String hexHW = pieces[pieces.length - 1]; if (hexHW.equals(hwVersion)) { hexPath = FilenameUtils.concat("bean_fw_advanced_callbacks", filename); break; } } } assertThat(hexPath).isNotNull(); InputStream imageStream = getContext().getAssets().open(hexPath); StringWriter writer = new StringWriter(); IOUtils.copy(imageStream, writer); String timestamp = Long.toString(System.currentTimeMillis() / 1000); SketchHex sketchHex = SketchHex.create(timestamp, writer.toString()); final CountDownLatch sketchLatch = new CountDownLatch(1); Callback<UploadProgress> onProgress = new Callback<UploadProgress>() { @Override public void onResult(UploadProgress result) { System.out.println("On Result: " + result); } }; Runnable onComplete = new Runnable() { @Override public void run() { System.out.println("all done!"); sketchLatch.countDown(); } }; bean.programWithSketch(sketchHex, onProgress, onComplete); sketchLatch.await(120, TimeUnit.SECONDS); SketchMetadata metadata = getSketchMetadata(bean); if (!metadata.hexName().equals(timestamp)) { fail(String.format("Unexpected Sketch name: %s != %s", metadata.hexName(), timestamp)); } }
Example #7
Source File: TestBeanAdvanced.java From bean-sdk-android with MIT License | 4 votes |
@Suppress public void testBeanListenerCallbacks() throws Exception { /** * This tests all of the "Happy Path" BeanListener callbacks * - onConnected * - onSerialMessageReceived (TODO: Broken, test when fixed) * - onScratchValueChanged * - onDisconnected * * This test does not test failure callbacks: * - onConnectionFailed * - onError * * Note: This test requires a Bean with a particular sketch loaded. The * Sketch needed can be found in sdk/src/androidTest/assets/bean_fw_advanced_callbacks. */ final Bean bean = discoverBean(); // TODO: The latch should have a value of 5 when all callbacks are operational final CountDownLatch testCompletionLatch = new CountDownLatch(4); BeanListener beanListener = new BeanListener() { private void disconnect() { if (testCompletionLatch.getCount() == 1) { Log.i(TAG, "Disconnecting!"); bean.disconnect(); } } @Override public void onConnected() { Log.i(TAG, "SUCCESS: Connected"); testCompletionLatch.countDown(); triggerBeanScratchChange(bean); triggerBeanSerialMessage(bean); triggerReadRemoteRssi(bean); } @Override public void onConnectionFailed() { Log.e(TAG, "FAILURE: Connection failed"); fail("Connection failed!"); } @Override public void onDisconnected() { Log.i(TAG, "SUCCESS: Disconnected"); testCompletionLatch.countDown(); } @Override public void onSerialMessageReceived(byte[] data) { Log.i(TAG, "SUCCESS: Serial Message Received!"); // TODO: Broken, never called! testCompletionLatch.countDown(); disconnect(); } @Override public void onScratchValueChanged(ScratchBank bank, byte[] value) { Log.i(TAG, "SUCCESS: Scratch Value Changed!"); testCompletionLatch.countDown(); disconnect(); } @Override public void onError(BeanError error) { Log.e(TAG, "FAILURE: Bean error " + error.toString()); fail(error.toString()); } @Override public void onReadRemoteRssi(final int rssi) { Log.i(TAG, "SUCCESS: Read remote RSSI"); testCompletionLatch.countDown(); disconnect(); } }; bean.connect(getContext(), beanListener); testCompletionLatch.await(60, TimeUnit.SECONDS); if (testCompletionLatch.getCount() != 0) { fail("Not all callbacks fired"); } }
Example #8
Source File: TestBeanAdvanced.java From bean-sdk-android with MIT License | 4 votes |
@Suppress public void testConnectMultipleBeansWithSameListener() throws InterruptedException { /* This test requires at least 3 beans nearby to pass */ final List<Bean> beans = discoverBeans(3); final Bean beanA = beans.get(0); final Bean beanB = beans.get(1); final Bean beanC = beans.get(2); final CountDownLatch connectionLatch = new CountDownLatch(2); final HashMap<String, Boolean> connectionState = new HashMap<>(); connectionState.put("bean_a_connected", false); connectionState.put("bean_b_connected", false); BeanListener beanListener = new BeanListener() { @Override public void onConnected() { if (connectionState.get("bean_a_connected") == false) { if (beanA.isConnected()) { connectionState.put("bean_a_connected", true); connectionLatch.countDown(); } } if (connectionState.get("bean_b_connected") == false) { if (beanB.isConnected()) { connectionState.put("bean_b_connected", true); connectionLatch.countDown(); } } if (beanC.isConnected()) { fail("Bean C not suppose to connect!"); } } @Override public void onConnectionFailed() { fail("Connection failed!"); } @Override public void onDisconnected() { } @Override public void onSerialMessageReceived(byte[] data) { } @Override public void onScratchValueChanged(ScratchBank bank, byte[] value) { } @Override public void onError(BeanError error) { fail(error.toString()); } @Override public void onReadRemoteRssi(final int rssi) { System.out.println("onReadRemoteRssi: " + rssi); } }; beanA.connect(getContext(), beanListener); beanB.connect(getContext(), beanListener); connectionLatch.await(60, TimeUnit.SECONDS); // No need to assert anything, implicit success based on connection latch }
Example #9
Source File: ErrorUrlTest.java From crosswalk-cordova-android with Apache License 2.0 | 4 votes |
@Suppress public void testPreconditions(){ assertNotNull(innerContainer); assertNotNull(testView); }
Example #10
Source File: TestBeanBLE.java From bean-sdk-android with MIT License | 3 votes |
@Suppress public void testBLE() throws InterruptedException { // Scan/Discover BluetoothDevice device = findDevice(); // Connect to closest device (hopefully a Bean) BluetoothGatt gatt = connectGatt(device); // Clear Android Cache refreshDeviceCache(gatt); // Discover services discoverServices(gatt); // Read HW version from Device Info Service readHardwareVersion(gatt); // Enable notifications on OAD Identify char enableNotificationOADIdentify(gatt); // Write 0x0000 to OAD Identify char writeCharacteristicOADIdentify(gatt); // Receive notification receiveNotificationOADIdentify(); gatt.disconnect(); gatt.close(); }