Skip to content
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
.idea
22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .idea/gradle.xml

This file was deleted.

46 changes: 0 additions & 46 deletions .idea/misc.xml

This file was deleted.

23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: android
jdk: oraclejdk8

android:
components:
- tools
- platform-tools
- build-tools-25.0.0
- android-25
- extra-android-m2repository
- sys-img-armeabi-v7a-android-16

before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

before_script:
- echo no | android create avd --force -n test -t android-16 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- sleep 10
- adb shell input keyevent 82
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# ![RC Car Logo](https://github.com/fouliex/AndroidRcCar/blob/master/resources/images/RobotCarLogo.jpg) Android RC Car(In Progress)
**BlueBot**

A **Blue**tooth Android app that controls an Arduino based Ro**bot**.
# ![RC Car Logo](https://github.com/fouliex/AndroidRcCar/blob/master/resources/images/RobotCarLogo.jpg) Android BlueBot
## Wiki Contents
1. [**Assemble the RC Car**](https://github.com/fouliex/AndroidRcCar/wiki/Assemble-the-RC-Car)
2. [**DC Motor Construction**](https://github.com/fouliex/AndroidRcCar/wiki/RC-DC-Motor-Construction)
2. [**DC Motor Construction**](https://github.com/fouliex/AndroidRcCar/wiki/RC-DC-Motor-Construction)

You can get the Arduino Smart Robot Car Kit from [**Amazon**](https://www.amazon.com/gp/product/B01DPH0SWY/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1)

[![Build Status](https://travis-ci.org/fouliex/BlueBot.svg?branch=master)](https://travis-ci.org/fouliex/BlueBot)
24 changes: 16 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.car.rc.example.fouliex.rccar"
applicationId "com.bluebot"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
Expand All @@ -19,13 +19,21 @@ android {
}
}

ext {
supportVersion = '25.3.1'
espressoVersion = '2.2.2'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support.constraint:constraint-layout:1.0.2"
compile "com.akexorcist:bluetoothspp:1.0.0"
compile "com.android.support:support-v4:$supportVersion"
compile project(':bluebotruntimelib')
testCompile 'junit:junit:4.12'
androidTestCompile "com.android.support:support-v4:$supportVersion"
androidTestCompile("com.android.support.test.espresso:espresso-core:$espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.akexorcist:bluetoothspp:1.0.0'
testCompile 'junit:junit:4.12'
androidTestCompile "com.android.support.test.espresso:espresso-intents:$espressoVersion"
}
56 changes: 56 additions & 0 deletions app/src/androidTest/java/com/bluebot/MainActivitySpec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.bluebot;

import android.support.test.espresso.intent.Intents;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.bluebot.droid.ide.BlueBotIDEActivity;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static android.support.test.espresso.matcher.ViewMatchers.isClickable;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
* Created by Clifton Craig on 4/12/17.
*/
@Ignore
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivitySpec {
@Rule
public ActivityTestRule<MainActivity> activityTestRule = new ActivityTestRule<>(MainActivity.class);

@Before
public void setUp() throws Exception {
Intents.init();
}

@After
public void tearDown() throws Exception {
Intents.release();

}

@Test
public void shouldHaveAnIDEButton() throws Exception {
onView(withText("IDE")).check(matches(isClickable()));
}

@Test
public void clickingTheIDEButtonShouldLaunchTheIDEActivity() throws Exception {
onView(withText("IDE")).perform(click());
intended(hasComponent(BlueBotIDEActivity.class.getName()));
}
}
132 changes: 132 additions & 0 deletions app/src/androidTest/java/com/bluebot/droid/ide/BlueBotIDESpec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package com.bluebot.droid.ide;

import android.support.test.espresso.action.ViewActions;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.bluebot.ui.RequestProcessor;
import com.bluebot.ui.ResponseHandler;
import com.bluebot.ui.UIRequestTypes;
import com.bluebot.ui.UIResponseType;

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

import java.util.HashMap;
import java.util.Map;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

/**
* Created by Clifton Craig on 4/8/17.
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class BlueBotIDESpec implements RequestProcessor {
@Rule
public final ActivityTestRule<BlueBotIDEActivity> activityTestRule = new ActivityTestRule<>(BlueBotIDEActivity.class);
private String dataPassedToRequestProcessor;
private String requestTypePassedToRequestProcessor;
private ResponseHandler responseHandlerPassedToBind;

@Test
public void shouldIncludeWindowTitleOnScreen() {
onView(withText("BlueBot IDE")).check(matches(isDisplayed()));
}

@Test
public void shouldHaveAPlaceToEnterCode() throws Exception {
onView(withContentDescription("Code Entry")).check(matches(isDisplayed()));
}

@Test
public void shouldHaveAButtonToRunCode() throws Exception {
onView(withContentDescription("Run")).check(matches(isDisplayed()));
}

@Test
public void theIDEShouldDependOnARequestProcessor() throws Exception {
activityTestRule.getActivity().setRequestProcessor(this);
}

@Override
public void bind(ResponseHandler responseHandler) {
this.responseHandlerPassedToBind = responseHandler;
}

@Test
public void theIDEActivityShouldBindTheRequestProcessorWhenSet() throws Exception {
activityTestRule.getActivity().setRequestProcessor(this);
assertNotNull(responseHandlerPassedToBind);
}

@Test
public void boundResponseHandlerShouldShowErrorMEssageInTheUI() throws Exception {
//Given
theIDEActivityShouldBindTheRequestProcessorWhenSet();
//When we have an error response
Map<String, Object> response = new HashMap<String, Object>() {{
put(UIResponseType.ERROR, "Stupidity Error!");
}};
//And we send it to the responseHandler...
responseHandlerPassedToBind.responseForRequest(UIRequestTypes.EXECUTE_CODE, response);
//Then the UI should light up with the error
onView(withContentDescription("Error message")).check(matches(isDisplayed()));
}

@Test
public void boundResponseHandlerShouldNotShowErrorOnSuccess() throws Exception {
//Given
theIDEActivityShouldBindTheRequestProcessorWhenSet();
//When we have an error response
Map<String, Object> response = new HashMap<String, Object>() {{
put(UIResponseType.SUCCESS, "");
}};
//And we send it to the responseHandler...
responseHandlerPassedToBind.responseForRequest(UIRequestTypes.EXECUTE_CODE, response);
//Then the UI should **NOT** light up with the error
onView(withContentDescription("Error message")).check(matches(not(isDisplayed())));
}

@Test
public void theIDEActivityShouldNotShowErrorMessagesByDefault() throws Exception {
onView(withContentDescription("Error message")).check(matches(not(isDisplayed())));
}

@Override
public void processRequest(String requestType, Object data) {
this.requestTypePassedToRequestProcessor = requestType;
this.dataPassedToRequestProcessor = String.valueOf(data);
}

@Test
public void enteringCodeAndPressingRunShouldInvokeCodeExecutor() throws Exception {
//Given this test case pretends to be a code executor
activityTestRule.getActivity().setRequestProcessor(this);
//And some BlueBot code...
String someBlueBotCode = "wake up bot\n" +
"spin around\n" +
"say hello";

//When we type the code in...
onView(withContentDescription("Code Entry"))
.perform(ViewActions.typeText(someBlueBotCode));

//And click the run button
onView(withContentDescription("Run")).perform(ViewActions.click());

//Then our Code Executor should be asked to execute someBlueBotCode
assertEquals("An EXECUTE_CODE request should be given.", UIRequestTypes.EXECUTE_CODE, requestTypePassedToRequestProcessor);
//And our Code Executor should be asked to execute someBlueBotCode
assertEquals("The given code should be executed.", someBlueBotCode, dataPassedToRequestProcessor);
}
}
Loading