Добавить обучение и полный экран результата
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package com.projectsacrifice.game;
|
||||
|
||||
import androidx.test.core.app.ActivityScenario;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class OnboardingAndResultFlowTest {
|
||||
@Test
|
||||
public void tutorialIsOptionalNonBlockingAndDoesNotRepeatAfterRecreation() {
|
||||
try (ActivityScenario<MainActivity> activity = ActivityScenario.launch(MainActivity.class)) {
|
||||
activity.onActivity(owner -> {
|
||||
GameView view = owner.gameViewForAutomation();
|
||||
view.resetOnboardingForAutomation();
|
||||
view.startLevelForAutomation(1);
|
||||
assertTrue(view.onboardingVisibleForAutomation());
|
||||
assertEquals(OnboardingFlow.Step.MOVEMENT,
|
||||
view.onboardingStepForAutomation());
|
||||
|
||||
view.setAutomationInput(false, true, false);
|
||||
assertTrue("Tutorial must not disable gameplay controls",
|
||||
view.automationSnapshot().inputActive());
|
||||
|
||||
view.advanceOnboardingForAutomation();
|
||||
view.advanceOnboardingForAutomation();
|
||||
view.advanceOnboardingForAutomation();
|
||||
assertFalse(view.onboardingVisibleForAutomation());
|
||||
});
|
||||
|
||||
activity.recreate();
|
||||
activity.onActivity(owner -> {
|
||||
GameView view = owner.gameViewForAutomation();
|
||||
view.startLevelForAutomation(1);
|
||||
assertFalse(view.onboardingVisibleForAutomation());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completionShowsRunAndSavedBestAndAllResultRoutesPreserveState() {
|
||||
try (ActivityScenario<MainActivity> activity = ActivityScenario.launch(MainActivity.class)) {
|
||||
activity.onActivity(owner -> {
|
||||
GameView view = owner.gameViewForAutomation();
|
||||
view.selectNextControlSizeForAutomation();
|
||||
String selectedSize = view.controlSettingsForAutomation().controlSizeLabel();
|
||||
|
||||
view.startLevelForAutomation(1);
|
||||
view.finishLevelForAutomation(2, 42_000L);
|
||||
CompletionResult result = view.completionResultForAutomation();
|
||||
assertNotNull(result);
|
||||
assertTrue(view.resultVisibleForAutomation());
|
||||
assertEquals(2, result.currentDeaths());
|
||||
assertEquals(42_000L, result.currentTimeMs());
|
||||
assertTrue(result.bestDeaths() <= result.currentDeaths());
|
||||
assertTrue(result.bestTimeMs() <= result.currentTimeMs());
|
||||
assertTrue(view.levelCompletedForAutomation(1));
|
||||
|
||||
view.replayFromResultForAutomation();
|
||||
assertEquals(1, view.automationSnapshot().levelNumber());
|
||||
assertFalse(view.automationSnapshot().completed());
|
||||
assertEquals(selectedSize, view.controlSettingsForAutomation().controlSizeLabel());
|
||||
assertTrue(view.levelCompletedForAutomation(1));
|
||||
|
||||
view.finishLevelForAutomation(1, 35_000L);
|
||||
view.nextLevelFromResultForAutomation();
|
||||
assertEquals(2, view.automationSnapshot().levelNumber());
|
||||
assertEquals(selectedSize, view.controlSettingsForAutomation().controlSizeLabel());
|
||||
assertTrue(view.levelCompletedForAutomation(1));
|
||||
|
||||
view.finishLevelForAutomation(1, 35_000L);
|
||||
view.levelsFromResultForAutomation();
|
||||
assertTrue(view.levelsVisibleForAutomation());
|
||||
assertEquals(selectedSize, view.controlSettingsForAutomation().controlSizeLabel());
|
||||
assertTrue(view.levelCompletedForAutomation(2));
|
||||
view.resetControlSettingsForAutomation();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.projectsacrifice.game;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class OnboardingStoreTest {
|
||||
@Test
|
||||
public void dismissalSurvivesStoreRecreation() {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
OnboardingStore first = new OnboardingStore(context);
|
||||
first.resetForAutomation();
|
||||
assertFalse(first.isComplete());
|
||||
|
||||
first.markComplete();
|
||||
|
||||
assertTrue(new OnboardingStore(context).isComplete());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user