Skip to content

Commit

Permalink
Test java to kotlin migration (#1999)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 authored Jul 21, 2023
1 parent 98e4602 commit fa4442a
Show file tree
Hide file tree
Showing 35 changed files with 2,619 additions and 2,913 deletions.
79 changes: 31 additions & 48 deletions ...sxdroid/tests/CenterListFragmentTest.java → ...fosxdroid/tests/CenterListFragmentTest.kt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,79 +1,62 @@
package com.mifos.mifosxdroid.tests;
package com.mifos.mifosxdroid.tests

import android.test.ActivityInstrumentationTestCase2;
import android.test.ViewAsserts;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;

import com.mifos.mifosxdroid.online.CentersActivity;
import android.test.ActivityInstrumentationTestCase2
import android.util.Log
import android.view.KeyEvent
import android.view.View
import android.widget.ListView

/**
* Created by Gabriel Esteban on 12/12/14.
*/
@Suppress // TODO: Fix NPE and Rewrite Test with new Documentation
public class CenterListFragmentTest extends ActivityInstrumentationTestCase2<CentersActivity> {

public final String LOG_TAG = getClass().getSimpleName();

CentersActivity centersActivity;

ListView lv_centers_list;

public CenterListFragmentTest() {
super(CentersActivity.class);
}

@Override
protected void setUp() throws Exception {
super.setUp();
centersActivity = getActivity();
class CenterListFragmentTest : ActivityInstrumentationTestCase2<CentersActivity?>(
CentersActivity::class.java
) {
val LOG_TAG: String = javaClass.getSimpleName()
var centersActivity: CentersActivity? = null
var lv_centers_list: ListView? = null
@Throws(Exception::class)
protected fun setUp() {
super.setUp()
centersActivity = getActivity()
//API wait for charging all centers
Thread.sleep(6000);
Thread.sleep(6000)
//instantiating view objects
//lv_centers_list = (ListView) centersActivity.findViewById(R.id.lv_center_list);
}

@SmallTest
public void testViewsAreNotNull() {
assertNotNull(lv_centers_list);
fun testViewsAreNotNull() {
assertNotNull(lv_centers_list)
}

@SmallTest
public void testViewsAreOnTheScreen() {
final View decorView = centersActivity.getWindow().getDecorView();

ViewAsserts.assertOnScreen(decorView, lv_centers_list);
fun testViewsAreOnTheScreen() {
val decorView: View = centersActivity.getWindow().getDecorView()
ViewAsserts.assertOnScreen(decorView, lv_centers_list)
}

@SmallTest
public void testOpenClientActivity() throws InterruptedException {
@Throws(InterruptedException::class)
fun testOpenClientActivity() {
try {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
lv_centers_list.performItemClick(null, 0, 0);
}
});
} catch (Throwable throwable) {
Log.d(LOG_TAG, throwable.getMessage());
runTestOnUiThread(Runnable { lv_centers_list!!.performItemClick(null, 0, 0) })
} catch (throwable: Throwable) {
Log.d(LOG_TAG, throwable.message!!)
}

//if something went wrong instantiating the group fragment, performItemClick will throw
// and exception

//waiting for the API
Thread.sleep(2000);

this.sendKeys(KeyEvent.KEYCODE_BACK);
Thread.sleep(2000)
this.sendKeys(KeyEvent.KEYCODE_BACK)

//waiting again for the API
Thread.sleep(6000);
Thread.sleep(6000)
}

/**
* - open center list, check title is "Centers"
* - open a center and check title is "Groups"
Expand Down Expand Up @@ -118,4 +101,4 @@ public void testCorrectTitles() throws InterruptedException {
}*/
}
}

This file was deleted.

Loading

0 comments on commit fa4442a

Please sign in to comment.