-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
runner
authored and
runner
committed
Oct 5, 2022
1 parent
d25a3c7
commit 9824957
Showing
36 changed files
with
305 additions
and
87 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
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
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
55 changes: 55 additions & 0 deletions
55
...va/com/unity3d/ads/test/instrumentation/services/core/device/GameSessionIdReaderTest.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,55 @@ | ||
package com.unity3d.ads.test.instrumentation.services.core.device; | ||
|
||
import static com.unity3d.services.core.device.reader.JsonStorageKeyNames.GAME_SESSION_ID_NORMALIZED_KEY; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import com.unity3d.services.core.device.Storage; | ||
import com.unity3d.services.core.device.StorageManager; | ||
import com.unity3d.services.core.device.reader.GameSessionIdReader; | ||
import com.unity3d.services.core.properties.ClientProperties; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class GameSessionIdReaderTest { | ||
|
||
@Before | ||
public void setup() { | ||
ClientProperties.setApplicationContext(InstrumentationRegistry.getInstrumentation().getTargetContext()); | ||
} | ||
|
||
@Test | ||
public void testGameSessionIdReader() { | ||
Long gameSessionId = GameSessionIdReader.getInstance().getGameSessionIdAndStore(); | ||
|
||
// validate we get a gameSessionId | ||
Assert.assertNotNull(gameSessionId); | ||
Assert.assertEquals(12, (Long.toString(gameSessionId)).length()) ; | ||
// validate we store the value | ||
StorageManager.init(InstrumentationRegistry.getInstrumentation().getTargetContext()); | ||
StorageManager.initStorage(StorageManager.StorageType.PRIVATE); | ||
Storage storage = StorageManager.getStorage(StorageManager.StorageType.PRIVATE); | ||
Long storedId = null; | ||
if (storage != null) { | ||
storedId = (Long) storage.get(GAME_SESSION_ID_NORMALIZED_KEY); | ||
} | ||
Assert.assertEquals(gameSessionId, storedId); | ||
// validate on consecutive requests we get the same value | ||
Long gameSessionId2 = GameSessionIdReader.getInstance().getGameSessionId(); | ||
Assert.assertEquals(gameSessionId, gameSessionId2); | ||
// validate even on storage change we get same value | ||
if (storage != null) { | ||
storage.set(GAME_SESSION_ID_NORMALIZED_KEY, "newValueFromWebview"); | ||
storage.writeStorage(); | ||
} | ||
Long gameSessionId3 = GameSessionIdReader.getInstance().getGameSessionId(); | ||
Assert.assertEquals(gameSessionId, gameSessionId3); | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.