Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh related code removed #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ android {
productFlavors {
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
resources {
excludes += ['META-INF/proguard/androidx-annotations.pro']
}
}
namespace 'com.ublox.BLE'
}

dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation project(':meshprovision')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v13:28.0.0'
testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.hamcrest.Matcher;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import static android.app.Activity.RESULT_OK;
Expand Down
10 changes: 5 additions & 5 deletions app/src/androidTest/java/com/ublox/BLE/TestChatFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import com.ublox.BLE.activities.MainActivity;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
Expand All @@ -29,13 +29,13 @@ public class TestChatFragment {
@Rule
public ActivityTestRule<MainActivity> act = new MainWithBluetoothTestRule();

@Before
@BeforeEach
public void setup() {
waitFor(500);
onView(withText("CHAT")).perform(click());
}

@Test
@org.junit.jupiter.api.Test
public void sendMessage_connected() {
typeMessage("Hello World!");
onView(allOf(withId(R.id.tvMessage), withText("Hello World!"))).check(matches(isDisplayed()));
Expand All @@ -48,7 +48,7 @@ public void sendMessage_notConnected() {
onToast(act.getActivity(), "You need to be connected to a device in order to do this");
}

@Test
@org.junit.jupiter.api.Test
public void sendMessage_withCr() {
onView(withId(R.id.swSendWithCR)).perform(click());
typeMessage("Hello World!");
Expand Down
6 changes: 3 additions & 3 deletions app/src/androidTest/java/com/ublox/BLE/TestDatapump.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import com.ublox.BLE.activities.MainActivity;

import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
Expand All @@ -24,7 +24,7 @@ public class TestDatapump {
@Rule
public ActivityTestRule<MainActivity> activityTestRule = new MainWithBluetoothTestRule();

@Before
@BeforeEach
public void setup() {
waitFor(500);
onView(withText("TEST")).perform(click());
Expand Down
28 changes: 14 additions & 14 deletions app/src/androidTest/java/com/ublox/BLE/TestDevicesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import com.ublox.BLE.bluetooth.BluetoothPeripheral;
import com.ublox.BLE.utils.GattAttributes;

import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -46,7 +46,7 @@ public class TestDevicesActivity {
@Rule
public GrantPermissionRule permissionRule = GrantPermissionRule.grant(Manifest.permission.ACCESS_COARSE_LOCATION);

@Before
@BeforeEach
public void setup() {
mockScanner = mock(BluetoothCentral.class);

Expand All @@ -57,35 +57,35 @@ public void setup() {
}
}

@Test
@org.junit.jupiter.api.Test
public void openAboutPage() {
onView(withId(R.id.menu_about)).perform(click());
onView(withId(R.id.bVisit)).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void startCallsScan() {
onView(withId(R.id.menu_scan)).perform(click());
verify(mockScanner, atLeastOnce()).scan(any());
}

@Test
@org.junit.jupiter.api.Test
public void whenScanStartedDisplayStop() {
when(mockScanner.getState()).thenReturn(BluetoothCentral.State.SCANNING);
act.getActivity().centralChangedState(mockScanner);

onView(withId(R.id.menu_stop)).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void stopCallsStopOnScan() {
when(mockScanner.getState()).thenReturn(BluetoothCentral.State.SCANNING);
act.getActivity().centralChangedState(mockScanner);
onView(withId(R.id.menu_stop)).perform(click());
verify(mockScanner, atLeastOnce()).stop();
}

@Test
@org.junit.jupiter.api.Test
public void whenStoppedDisplayScanAgain() {
when(mockScanner.getState()).thenReturn(
BluetoothCentral.State.SCANNING,
Expand All @@ -99,7 +99,7 @@ public void whenStoppedDisplayScanAgain() {
onView(withId(R.id.menu_scan)).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void displayScannedPeripherals() {
listMockedPeripherals();

Expand All @@ -109,7 +109,7 @@ public void displayScannedPeripherals() {
onData(withDevice("00:00:00:00:00:01")).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void filterWithSps() {
listMockedPeripherals();
onView(withId(R.id.checkBoxSps)).perform(click());
Expand All @@ -118,7 +118,7 @@ public void filterWithSps() {
onData(withDevice("00:00:00:00:00:01")).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void filterDevicesAreSavedAnyway() {
onView(withId(R.id.checkBoxSps)).perform(click());
listMockedPeripherals();
Expand All @@ -130,7 +130,7 @@ public void filterDevicesAreSavedAnyway() {
onData(withDevice("00:00:00:00:00:01")).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void filterOnName() {
listMockedPeripherals();

Expand All @@ -150,7 +150,7 @@ public void filterNameAlsoWorksOnAddress() {
onData(withDevice("00:00:00:00:00:02")).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void filterCombineNameAndSps() {
listMockedPeripherals();

Expand All @@ -161,7 +161,7 @@ public void filterCombineNameAndSps() {
}


@Test()
@org.junit.jupiter.api.Test()
public void connect() {
listMockedPeripherals();
try {
Expand Down
8 changes: 4 additions & 4 deletions app/src/androidTest/java/com/ublox/BLE/TestMainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import com.ublox.BLE.activities.MainActivity;

import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
Expand All @@ -25,7 +25,7 @@ public class TestMainActivity {
@Rule
public ActivityTestRule<MainActivity> act = new MainWithBluetoothTestRule();

@Before
@BeforeEach
public void setup() {
waitFor(500);
}
Expand All @@ -46,7 +46,7 @@ public void disconnectFromDevice() {
onView(withId(R.id.menu_connect)).check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void reconnectToDevice() {
onView(withId(R.id.menu_disconnect)).perform(click());
onView(withId(R.id.menu_connect)).perform(click());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.ublox.BLE.activities.MainActivity;

import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import com.ublox.BLE.activities.MainActivity;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onData;
Expand All @@ -26,7 +26,7 @@ public class TestServicesFragment {
@Rule
public ActivityTestRule<MainActivity> act = new MainWithBluetoothTestRule();

@Before
@BeforeEach
public void setup() {
waitFor(500);
onView(withText("SERVICES")).perform(click());
Expand Down
40 changes: 20 additions & 20 deletions app/src/androidTest/java/com/ublox/BLE/TestTestFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import com.ublox.BLE.activities.MainActivity;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
Expand All @@ -32,19 +32,19 @@ public class TestTestFragment {
@Rule
public ActivityTestRule<MainActivity> act = new MainWithBluetoothTestRule();

@Before
@BeforeEach
public void setup() {
waitFor(500);
onView(withText("TEST")).perform(click());
}

@Test
@org.junit.jupiter.api.Test
public void requestMTU_empty() {
onView(withId(R.id.bMtu)).perform(click(), click());
onToast(act.getActivity(), "You must enter a number").check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void requestMTU_tooSmall() {
enterMTU("0");
onView(withId(R.id.tvMtuSize)).check(matches(not(withText("0"))));
Expand All @@ -56,81 +56,81 @@ public void requestMTU_min() {
onView(withId(R.id.tvMtuSize)).check(matches(withText("23")));
}

@Test
@org.junit.jupiter.api.Test
public void requestMTU_max() {
enterMTU("247");
onView(withId(R.id.tvMtuSize)).check(matches(withText("247")));
}

@Test
@org.junit.jupiter.api.Test
public void requestMTU_tooLarge() {
enterMTU("300");
onView(withId(R.id.tvMtuSize)).check(matches(withText("247")));
}

@Test
@org.junit.jupiter.api.Test
public void toggleCredits() {
onView(withId(R.id.swCredits)).perform(click());
onView(withId(R.id.swCredits)).check(matches(isChecked()));
}

@Ignore("Datapumping seems to lock ui here, might be badly mocked")
@Test
@Disabled("Datapumping seems to lock ui here, might be badly mocked")
@org.junit.jupiter.api.Test
public void toggleCredits_ongoing() {
onView(withId(R.id.swTxTest)).perform(click());
onView(withId(R.id.swCredits)).perform(click());
onView(withId(R.id.swCredits)).check(matches(isNotChecked()));
}

@Test
@org.junit.jupiter.api.Test
public void sendOnePacket() {
onView(withText("packet")).perform(click());
onView(withId(R.id.swTxTest)).perform(click());
onView(withId(R.id.tvTxCounter)).check(matches(withText("20 B")));
}

@Ignore("Datapumping seems to lock ui here, might be badly mocked")
@Test
@Disabled("Datapumping seems to lock ui here, might be badly mocked")
@org.junit.jupiter.api.Test
public void sendContinuous() {
onView(withId(R.id.continuous)).perform(click());
onView(withId(R.id.swTxTest)).perform(click());
onView(withId(R.id.tvTxCounter)).check(matches(not(withText("0 B"))));
}

@Test
@org.junit.jupiter.api.Test
public void clearRx() {
onView(withId(R.id.bRxReset)).perform(click());
onView(withId(R.id.tvRxAvg)).check(matches(withText("0.00 kbps")));
}

@Test
@org.junit.jupiter.api.Test
public void setPacketEmpty() {
onView(withId(R.id.etPacketSize)).perform(click(), clearText(), closeSoftKeyboard());
onToast(act.getActivity(), "The packet length number too big or not valid!").check(matches(isDisplayed()));
}

@Test
@org.junit.jupiter.api.Test
public void toggleCredits_disconnectedNoChange() {
onView(withId(R.id.menu_disconnect)).perform(click());
onView(withId(R.id.swCredits)).perform(click());
onView(withId(R.id.swCredits)).check(matches(isNotChecked()));
}

@Test
@org.junit.jupiter.api.Test
public void requestMTU_disconnectedNoChange() {
onView(withId(R.id.menu_disconnect)).perform(click());
enterMTU("247");
onView(withId(R.id.tvMtuSize)).check(matches(not(withText("247"))));
}

@Test
@org.junit.jupiter.api.Test
public void startTxTest_disconnectedNoChange() {
onView(withId(R.id.menu_disconnect)).perform(click());
onView(withId(R.id.swTxTest)).perform(click());
onView(withId(R.id.tvTxCounter)).check(matches(withText("0 B")));
}

@Test
@org.junit.jupiter.api.Test
public void sendSinglePacketLargerThanMtuDisplaysCorrectly() {
onView(withText("packet")).perform(click());
onView(withId(R.id.etPacketSize)).perform(click(), clearText(), typeText("32"), closeSoftKeyboard());
Expand Down
Loading