This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from bitstadium/release/4.0.0-beta.1
Add 4.0.0-beta.1 Public Beta Version
- Loading branch information
Showing
52 changed files
with
6,179 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Mon Aug 24 13:43:45 CEST 2015 | ||
#Fri Jan 29 15:01:22 PST 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip |
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
18 changes: 18 additions & 0 deletions
18
hockeysdk/src/androidTest/java/net/hockeyapp/android/UtilTests.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,18 @@ | ||
package net.hockeyapp.android; | ||
|
||
import junit.framework.Assert; | ||
import junit.framework.TestCase; | ||
|
||
import net.hockeyapp.android.utils.Util; | ||
|
||
public class UtilTests extends TestCase { | ||
|
||
public void testValidAppIdentifierGetsConvertedToGuid() { | ||
String appIdentifier = " ca2aba1482cb9458a67b917930b202c8 "; | ||
String expected = "ca2aba14-82cb-9458-a67b-917930b202c8"; | ||
|
||
String actual = Util.convertAppIdentifierToGuid(appIdentifier); | ||
Assert.assertEquals(expected, actual); | ||
} | ||
|
||
} |
127 changes: 127 additions & 0 deletions
127
hockeysdk/src/androidTest/java/net/hockeyapp/android/metrics/ChannelTests.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,127 @@ | ||
package net.hockeyapp.android.metrics; | ||
|
||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.InstrumentationTestCase; | ||
|
||
import junit.framework.Assert; | ||
|
||
import net.hockeyapp.android.metrics.model.Data; | ||
import net.hockeyapp.android.metrics.model.Domain; | ||
import net.hockeyapp.android.metrics.model.Envelope; | ||
import net.hockeyapp.android.metrics.model.SessionState; | ||
import net.hockeyapp.android.metrics.model.SessionStateData; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.HashMap; | ||
|
||
import static org.mockito.Mockito.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class ChannelTests extends InstrumentationTestCase { | ||
|
||
// Helper | ||
private static final String MOCK_APP_ID = "appId"; | ||
private static final String MOCK_APP_VER = "appVer"; | ||
private static final String MOCK_IKEY = "iKey"; | ||
private static final String MOCK_OS_VER = "osVer"; | ||
private static final String MOCK_OS = "os"; | ||
private static final String MOCK_TAGS_KEY = "tagsKey"; | ||
private static final String MOCK_TAGS_VALUE = "tagsValue"; | ||
private PublicChannel sut; | ||
private PublicTelemetryContext mockTelemetryContext; | ||
private PublicPersistence mockPersistence; | ||
|
||
private static PublicTelemetryContext getMockTelemetryContext() { | ||
HashMap<String, String> tags = new HashMap<String, String>(); | ||
tags.put(MOCK_TAGS_KEY, MOCK_TAGS_VALUE); | ||
|
||
PublicTelemetryContext mockContext = mock(PublicTelemetryContext.class); | ||
when(mockContext.getPackageName()).thenReturn(MOCK_APP_ID); | ||
when(mockContext.getContextTags()).thenReturn(tags); | ||
when(mockContext.getAppVersion()).thenReturn(MOCK_APP_VER); | ||
when(mockContext.getInstrumentationKey()).thenReturn(MOCK_IKEY); | ||
when(mockContext.getOsVersion()).thenReturn(MOCK_OS_VER); | ||
when(mockContext.getOsName()).thenReturn(MOCK_OS); | ||
|
||
return mockContext; | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
injectInstrumentation(InstrumentationRegistry.getInstrumentation()); | ||
|
||
mockTelemetryContext = getMockTelemetryContext(); | ||
mockPersistence = mock(PublicPersistence.class); | ||
sut = new PublicChannel(mockTelemetryContext, mockPersistence); | ||
} | ||
|
||
@Test | ||
public void testInstanceInitialisation() { | ||
Assert.assertNotNull(sut); | ||
Assert.assertNotNull(sut.mTelemetryContext); | ||
Assert.assertEquals(mockTelemetryContext, sut.mTelemetryContext); | ||
Assert.assertNotNull(sut.mQueue); | ||
Assert.assertEquals(0, sut.mQueue.size()); | ||
} | ||
|
||
@Test | ||
public void testLoggingItemAddsToQueue() { | ||
Data<Domain> data = new Data<Domain>(); | ||
Channel.mMaxBatchCount = 3; | ||
Assert.assertEquals(0, sut.mQueue.size()); | ||
|
||
sut.enqueueData(data); | ||
Assert.assertEquals(1, sut.mQueue.size()); | ||
} | ||
|
||
@Test | ||
public void testQueueFlushesWhenMaxBatchCountReached() { | ||
PublicChannel.mMaxBatchCount = 3; | ||
Assert.assertEquals(0, sut.mQueue.size()); | ||
|
||
sut.enqueueData(new Data<Domain>()); | ||
Assert.assertEquals(1, sut.mQueue.size()); | ||
|
||
sut.enqueueData(new Data<Domain>()); | ||
Assert.assertEquals(2, sut.mQueue.size()); | ||
|
||
sut.enqueueData(new Data<Domain>()); | ||
Assert.assertEquals(0, sut.mQueue.size()); | ||
|
||
verify(mockPersistence).persist(any(String[].class)); | ||
} | ||
|
||
@Test | ||
public void testCreateEnvelopeForTelemetryData() { | ||
SessionStateData sessionStateData = new SessionStateData(); | ||
sessionStateData.setState(SessionState.START); | ||
Data<Domain> testData = new Data<Domain>(); | ||
testData.setBaseData(sessionStateData); | ||
testData.setBaseType(sessionStateData.getBaseType()); | ||
testData.QualifiedName = sessionStateData.getEnvelopeName(); | ||
|
||
Envelope result = sut.createEnvelope(testData); | ||
|
||
Assert.assertNotNull(result); | ||
Assert.assertNotNull(result.getTime()); | ||
Assert.assertEquals(MOCK_IKEY, result.getIKey()); | ||
Assert.assertNotNull(result.getTags()); | ||
Assert.assertEquals(1, result.getTags().size()); | ||
Assert.assertTrue(result.getTags().containsKey(MOCK_TAGS_KEY)); | ||
Assert.assertEquals(MOCK_TAGS_VALUE, result.getTags().get(MOCK_TAGS_KEY)); | ||
Assert.assertNotNull(result.getData()); | ||
SessionState actualState = ((SessionStateData) ((Data<Domain>) result.getData()).getBaseData()).getState(); | ||
Assert.assertEquals(SessionState.START, actualState); | ||
String actualBaseType = result.getData().getBaseType(); | ||
Assert.assertEquals(new SessionStateData().getBaseType(), actualBaseType); | ||
} | ||
} |
Oops, something went wrong.