@Test public void testConverters() { NativeManager manager = new NativeManager(); TestConverter converter = new TestConverter(); Type1 t1 = new Type1(10); Type2 t2 = new Type2(10); manager.registerConverter(converter); assertThat((Type2) manager.toNative(t1)).isEqualTo(t2); assertThat((Type1) manager.toNova(t2)).isEqualTo(t1); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); // findViewById(R.id.btn_start_update).setOnClickListener(new OnClickListener(){ // // @Override // public void onClick(View v) { // String text = NativeManager.nativeGetString(); // Toast.makeText(TestActivity.this, text, Toast.LENGTH_LONG).show(); // } // // }); // Initialize the native code NativeManager.nativeInit(); threadsEdit = (EditText) findViewById(R.id.threads_edit); iterationsEdit = (EditText) findViewById(R.id.iterations_edit); startButton = (Button) findViewById(R.id.start_button); logView = (TextView) findViewById(R.id.log_view); startButton.setOnClickListener( new OnClickListener() { public void onClick(View view) { int threads = getNumber(threadsEdit, 0); int iterations = getNumber(iterationsEdit, 0); if (threads > 0 && iterations > 0) { startThreads(threads, iterations); } } }); }
@Override protected void onDestroy() { // Free the native resources NativeManager.nativeFree(); super.onDestroy(); }
/** * Starts the given number of threads for iterations. * * @param threads thread count. * @param iterations iteration count. */ private void startThreads(int threads, int iterations) { // We will be implementing this method as we // work through the chapter NativeManager.posixThreads(threads, iterations); }