-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Locale Selection feature to the start of the game.
- Loading branch information
Showing
44 changed files
with
20,785 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
app/src/androidTest/java/com/linguaculturalists/phoenicia/components/ButtonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.linguaculturalists.phoenicia.components; | ||
|
||
import android.os.SystemClock; | ||
import android.test.ActivityInstrumentationTestCase2; | ||
import android.view.MotionEvent; | ||
|
||
import com.linguaculturalists.phoenicia.PhoeniciaGameTest; | ||
import com.linguaculturalists.phoenicia.TestActivity; | ||
import com.linguaculturalists.phoenicia.util.PhoeniciaContext; | ||
|
||
import org.andengine.input.touch.TouchEvent; | ||
|
||
/** | ||
* Created by mhall on 3/1/16. | ||
*/ | ||
public class ButtonTest extends PhoeniciaGameTest { | ||
|
||
@Override | ||
public void tearDown() throws Exception { | ||
this.game.scene.detachChildren(); | ||
super.tearDown(); | ||
} | ||
|
||
public void testCreateButton() { | ||
Button component = new Button(this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2, this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2, "Test", PhoeniciaContext.vboManager, null); | ||
assertNotNull(component); | ||
this.game.scene.attachChild(component); | ||
} | ||
|
||
public void testButtonClickedListener() { | ||
ClickTestListener listener = new ClickTestListener(); | ||
Button component = new Button(this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2, this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2, "Test", PhoeniciaContext.vboManager, listener); | ||
assertNotNull(component); | ||
|
||
assertFalse(listener.wasClicked); | ||
component.onClick(null, 0, 0f, 0f); | ||
assertTrue(listener.wasClicked); | ||
} | ||
|
||
public void testButtonTouchArea() { | ||
this.startGame(); | ||
ClickTestListener listener = new ClickTestListener(); | ||
Button component = new Button(this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2, this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2, "Test", PhoeniciaContext.vboManager, listener); | ||
assertNotNull(component); | ||
|
||
assertFalse(listener.wasClicked); | ||
|
||
final long uptimeMillis = SystemClock.uptimeMillis(); | ||
float[] surfaceCoordinates = this.activity.main_camera.getSurfaceCoordinatesFromSceneCoordinates(this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2); | ||
component.onAreaTouched(TouchEvent.obtain(this.activity.CAMERA_WIDTH / 2, this.activity.CAMERA_HEIGHT / 2, TouchEvent.ACTION_DOWN, 0, MotionEvent.obtain(uptimeMillis, uptimeMillis, MotionEvent.ACTION_DOWN, 0, 0, 0)), this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2); | ||
component.onAreaTouched(TouchEvent.obtain(this.activity.CAMERA_WIDTH / 2, this.activity.CAMERA_HEIGHT / 2, TouchEvent.ACTION_UP, 0, MotionEvent.obtain(uptimeMillis, uptimeMillis, MotionEvent.ACTION_UP, 0, 0, 0)), this.activity.CAMERA_WIDTH/2, this.activity.CAMERA_HEIGHT/2); | ||
assertTrue(listener.wasClicked); | ||
} | ||
|
||
private class ClickTestListener implements Button.OnClickListener { | ||
public boolean wasClicked = false; | ||
@Override | ||
public void onClicked(Button button) { | ||
this.wasClicked = true; | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
app/src/androidTest/java/com/linguaculturalists/phoenicia/locale/LocaleManagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.linguaculturalists.phoenicia.locale; | ||
|
||
import android.test.ActivityInstrumentationTestCase2; | ||
import android.test.AndroidTestCase; | ||
|
||
import com.linguaculturalists.phoenicia.PhoeniciaGameTest; | ||
import com.linguaculturalists.phoenicia.TestActivity; | ||
import com.linguaculturalists.phoenicia.util.PhoeniciaContext; | ||
|
||
import org.andengine.util.debug.Debug; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by mhall on 1/31/16. | ||
*/ | ||
public class LocaleManagerTest extends ActivityInstrumentationTestCase2<TestActivity> { | ||
|
||
private LocaleManager localeManager; | ||
private Map<String, String> locales; | ||
|
||
public LocaleManagerTest() { | ||
super(TestActivity.class); | ||
this.localeManager = new LocaleManager(); | ||
} | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
PhoeniciaContext.assetManager = this.getActivity().getAssets(); | ||
} | ||
|
||
@Override | ||
public void tearDown() throws Exception { | ||
super.tearDown(); | ||
} | ||
|
||
public void testLocaleScanning() { | ||
|
||
try { | ||
Map<String, String> locales = this.localeManager.scan("locales"); | ||
|
||
assertEquals(2, locales.size()); | ||
assertTrue(locales.containsKey("locales/en_us_test/manifest.xml")); | ||
assertTrue(locales.containsValue("US English, Testing")); | ||
|
||
assertTrue(locales.containsKey("locales/en_us_rural/manifest.xml")); | ||
assertTrue(locales.containsValue("US English, Rural Setting")); | ||
} catch (IOException e) { | ||
assertNull(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.