File tree Expand file tree Collapse file tree 4 files changed +25
-3
lines changed
androidTest/java/de/earthlingz/oerszebra
main/java/de/earthlingz/oerszebra Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 1
1
package de .earthlingz .oerszebra ;
2
2
3
+ import static androidx .test .platform .app .InstrumentationRegistry .getInstrumentation ;
4
+
3
5
import androidx .fragment .app .DialogFragment ;
4
6
import androidx .fragment .app .Fragment ;
5
7
import androidx .fragment .app .FragmentActivity ;
@@ -22,6 +24,7 @@ public void init() throws InterruptedException {
22
24
while (zebra == null && !zebra .initialized ()) {
23
25
Thread .sleep (100 );
24
26
}
27
+ getInstrumentation ().waitForIdleSync ();
25
28
}
26
29
27
30
void waitForOpenendDialogs (boolean dismiss ) throws InterruptedException {
Original file line number Diff line number Diff line change @@ -65,6 +65,22 @@ public void testIssue22() throws InterruptedException {
65
65
assertSame (32 , countSquares (ZebraEngine .PLAYER_BLACK ));
66
66
}
67
67
68
+ @ Test
69
+ public void testIssue79 () throws InterruptedException {
70
+ Intent intent = new Intent ();
71
+ intent .setAction (Intent .ACTION_SEND );
72
+ intent .setType ("message/rfc822" );
73
+ intent .putExtra (Intent .EXTRA_TEXT , "E6F6C4D6F7C3C6C7G6H6C8G8C2B2A2C1G7C5B3B6A6H8E3A3F4A1" );
74
+
75
+ zebra .runOnUiThread (() -> zebra .onNewIntent (intent ));
76
+ waitForOpenendDialogs (false );
77
+ assertSame (34 , countSquares (ZebraEngine .PLAYER_EMPTY ));
78
+ assertSame (15 , countSquares (ZebraEngine .PLAYER_WHITE ));
79
+ assertSame (15 , countSquares (ZebraEngine .PLAYER_BLACK ));
80
+ assertSame (32 ,zebra .getState ().getBlackScore ());
81
+ assertSame (32 ,zebra .getState ().getWhiteScore ());
82
+ }
83
+
68
84
@ Test
69
85
public void testCrash1 () throws InterruptedException {
70
86
Intent intent = new Intent ();
Original file line number Diff line number Diff line change @@ -70,7 +70,12 @@ public void processGameOver() {
70
70
int max = currentBoard .size () * currentBoard .size ();
71
71
if (getBlackScore () + getWhiteScore () < max ) {
72
72
//adjust result
73
- if (getBlackScore () > getWhiteScore ()) {
73
+ if (getBlackScore () == getWhiteScore ()) {
74
+ int empty = max - blackScore - whiteScore ;
75
+ this .blackScore = blackScore + empty /2 ;
76
+ this .whiteScore = whiteScore + empty /2 ;
77
+ }
78
+ else if (getBlackScore () > getWhiteScore ()) {
74
79
this .blackScore = max - getWhiteScore ();
75
80
} else {
76
81
this .whiteScore = max - getBlackScore ();
Original file line number Diff line number Diff line change @@ -220,7 +220,6 @@ void redo() {
220
220
}
221
221
222
222
void undo () {
223
- menu .findItem (R .id .menu_take_back ).setEnabled (false );
224
223
engine .undoMove (gameState );
225
224
}
226
225
@@ -715,7 +714,6 @@ public void onError(String error) {
715
714
716
715
@ Override
717
716
public void onBoard (GameState gameState ) {
718
- menu .findItem (R .id .menu_take_back ).setEnabled (true );
719
717
int sideToMove = gameState .getSideToMove ();
720
718
721
719
//triggers animations
You can’t perform that action at this time.
0 commit comments