Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil committed May 24, 2015
2 parents ca0607c + 01266bf commit 851b54d
Show file tree
Hide file tree
Showing 12 changed files with 499 additions and 44 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
compile 'com.jjoe64:graphview:4.0.1'
// Set this dependency to build and run Espresso tests
//androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
//androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.0'
//androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
// Set this dependency to build and run UI Automator tests
//androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.sloths.speedy.shortsounds.tests;

import com.sloths.speedy.shortsounds.model.AudioMixer;
import com.sloths.speedy.shortsounds.model.ShortSound;

import junit.framework.TestCase;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
* Test for AudioMixer class, the class that mixes tracks together
* into a single file.
*/
public class AudioMixerTest extends TestCase {

/*
* Tests the constructor to verify that it creates
* a valid AudioMixer
*/
public void testConstructor() {
ShortSound ss = new ShortSound();
AudioMixer am = new AudioMixer(ss);
assertNotNull("AudioMixer Constructor fail", am);
assertEquals("AudioMixer constructor made wrong" +
"ShortSound", ss, am.getShortSound());
}

/*
* Tests the generateAudioFile method from AudioMixer
* to make sure it generates a non null file properly.
*/
public void testGenerateAudioFile() {
ShortSound ss = new ShortSound();
AudioMixer am = new AudioMixer(ss);
File collection;
try {
collection = am.generateAudioFile();
} catch (IOException e) {
collection = null;
}
assertNotNull("GenerateAudioFile fail", collection);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
package com.sloths.speedy.shortsounds.tests;

import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;

import com.sloths.speedy.shortsounds.model.AudioPlayer;
import com.sloths.speedy.shortsounds.model.ShortSound;
import com.sloths.speedy.shortsounds.model.ShortSoundTrack;
import com.sloths.speedy.shortsounds.view.ShortSoundsApplication;

import junit.framework.TestCase;

import java.io.File;

/**
* Created by jbusc_000 on 5/15/2015.
* Tests general Functionality of the Audio Player Class
*/
public class AudioPlayerTest extends TestCase {

private String TAG = "AudioPlayerTest";
private static final String TAG = "AudioPlayerTest";
private static final String TEST_TITLE = "TestTrack";
private static final String TEST_FILE_NAME = "test-file-modified";

/*
Helper method, returns constructed player. Reduces redundent calls
Expand All @@ -25,6 +31,19 @@ private AudioPlayer constructEmptyPlayer() {
return new AudioPlayer(ss);
}

private AudioPlayer constructPlayerWithTracks() {
ShortSound ss = new ShortSound();
ShortSoundTrack sst = newSSTrack();
ss.addTrack(sst);
return new AudioPlayer(ss);
}

private ShortSoundTrack newSSTrack() {

ShortSoundTrack sst = new ShortSoundTrack(ShortSoundTrackTest.makeTestValues());
return sst;
}


///////////////////////////////////////////////////////////////////////////
// Constructor Test
Expand All @@ -41,6 +60,11 @@ public void testConstructor() {
assertEquals("Constructor Failure, Audio player in incorrect state after construction",
AudioPlayer.PlayerState.STOPPED_ALL, player.getPlayerState());
}

AudioPlayer player2 = constructPlayerWithTracks();
assertEquals("Constructor Failure, Incorrect number of tracks after constructing with " +
"premade short sound",
1, player2.getCurrentShortSound().getTracks().size());
}

///////////////////////////////////////////////////////////////////////////
Expand All @@ -53,9 +77,17 @@ public void testPlayAllChangesState() {
// test that state is properly changed
AudioPlayer player = constructEmptyPlayer();
player.playAll(0);
assertTrue("playAll Failure, not changing players state.",
assertTrue("playAll Failure, State should remain stopped if no tracks contained.",
!player.isPlayingAll());

//TODO Make tests capable of playing fake tracks to confirm behavior
// AudioPlayer player2 = constructPlayerWithTracks();
player.playAll(0);
assertTrue("playAll Failure, State should change to Playing when play all is called" +
"with non-null tracks in the audio player.",
player.isPlayingAll());


}

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -102,7 +134,6 @@ public void testPauseAllChangesState() {
// Tests that tracks can be added, played, paused, and stopped
///////////////////////////////////////////////////////////////////////////
public void testTrackFunctionality() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,34 @@
*/
public class EffectTest extends TestCase {

/**
* Tests to insure the constructor is working properly.
*/
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
public void testEQConstructor() {
Effect e = new EqEffect();
assertNotNull("Effect Constructor made a null object", e);
}

///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
public void testReverbConstructor() {
Effect e = new ReverbEffect();
assertNotNull("Effect Constructor made a null object", e);
}

///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
public void testTitles() {
Effect eq = new EqEffect();
Effect rv = new ReverbEffect();
assertEquals("EQ effect title wrong", eq.getTitleString(), "Equalizer");
assertEquals("Reverb effect title wrong", rv.getTitleString(), "Reverb");
}

///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
package com.sloths.speedy.shortsounds.tests;

import android.test.ActivityInstrumentationTestCase2;
import android.test.TouchUtils;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ViewAnimator;

import com.sloths.speedy.shortsounds.*;
import com.sloths.speedy.shortsounds.R;
import com.sloths.speedy.shortsounds.view.MainActivity;

import java.util.List;

/**
* Created by jbusc_000 on 5/15/2015.
* System test for the main activity and system interaction with other ui elements.
*/
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
MainActivity mMainActivity;
View mAnimator;
public MainActivityTest() {
public class MainActivityContentTest extends ActivityInstrumentationTestCase2<MainActivity> {
private MainActivity mMainActivity;
private View mAnimator;
private static final String TAG = "MAIN ACTIVITy TEST";

public MainActivityContentTest() {
super(MainActivity.class);
}

Expand All @@ -26,7 +33,9 @@ public MainActivityTest() {
*/
@Override
protected void setUp() throws Exception {
Log.d(TAG, "Set-Up");
super.setUp();
setActivityInitialTouchMode(true);
mMainActivity = getActivity();
mAnimator = mMainActivity.findViewById(R.id.view_animator);
}
Expand All @@ -40,10 +49,15 @@ public void testMainActivityNotNull() {
}

/**
* Test to insure that the views within the main activity are non-null.
* Test to ensure that the views within the main activity are non-null.
*/
@SmallTest
public void testMainActivityHasContent() {
assertNotNull("Animator is non-null", mAnimator);

assertNotNull("Animator null", mAnimator);
assertNotNull("SeekBar is null", mMainActivity.findViewById(R.id.seekBar));
assertNotNull("Record button is null", mMainActivity.findViewById(R.id.imageButtonPlay));
assertNotNull("DrawerLayout is null", mMainActivity.findViewById(R.id.drawer_layout));
}

}
Loading

0 comments on commit 851b54d

Please sign in to comment.