Skip to content

Commit 8ac5edf

Browse files
fix: tests
1 parent 4a5a5bd commit 8ac5edf

5 files changed

Lines changed: 13 additions & 12 deletions

File tree

sdk/src/androidTest/java/ly/count/android/sdk/DeviceInfoTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testGetDevice() {
7474
@Test
7575
public void testGetResolution() {
7676
final DisplayMetrics metrics = new DisplayMetrics();
77-
((WindowManager) TestUtils.getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics);
77+
((WindowManager) TestUtils.getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRealMetrics(metrics);
7878
final String expected = metrics.widthPixels + "x" + metrics.heightPixels;
7979
assertEquals(expected, regularDeviceInfo.mp.getResolution(TestUtils.getContext()));
8080
}

sdk/src/androidTest/java/ly/count/android/sdk/ModuleConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public void consentEnabled_allFeatures() throws JSONException, InterruptedExcept
212212

213213
Assert.assertEquals(2, TestUtils.getCurrentRQ().length);
214214
Assert.assertEquals(0, countlyStore.getEventQueueSize());
215-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 0, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false });
215+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 0, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false });
216216
TestUtils.validateRequest(TestUtils.commonDeviceId, TestUtils.map("location", ""), 1);
217217

218218
flow_allFeatures();
@@ -959,7 +959,7 @@ public void scenario_consentRequiredDisabled() throws JSONException {
959959

960960
Countly.sharedInstance().attribution().recordDirectAttribution("_special_test", "_special_test");
961961
Assert.assertEquals(3, TestUtils.getCurrentRQ().length); // changes nothing because no consent for attribution
962-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 1, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false });
962+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 1, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false });
963963
TestUtils.validateRequest(TestUtils.commonDeviceId, TestUtils.map("location", ""), 2);
964964
}
965965

sdk/src/androidTest/java/ly/count/android/sdk/ModuleConsentTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class ModuleConsentTests {
3232
Countly.CountlyFeatureNames.clicks,
3333
Countly.CountlyFeatureNames.scrolls,
3434
Countly.CountlyFeatureNames.content,
35+
Countly.CountlyFeatureNames.metrics,
3536
};
3637

3738
@Before
@@ -253,12 +254,12 @@ public void initTimeSetConsentRQ_4() throws JSONException {
253254
protected static void validateConsentRequest(String deviceId, int idx, boolean[] consents) {
254255
Map<String, Object> consentsMap =
255256
TestUtils.map("sessions", consents[0], "crashes", consents[1], "users", consents[2], "push", consents[3], "feedback", consents[4], "scrolls", consents[5], "remote-config", consents[6], "attribution", consents[7], "clicks", consents[8], "location", consents[9], "star-rating",
256-
consents[10], "events", consents[11], "views", consents[12], "apm", consents[13], "content", consents[14]);
257+
consents[10], "events", consents[11], "views", consents[12], "apm", consents[13], "content", consents[14], "metrics", consents[15]);
257258
TestUtils.validateRequest(deviceId, TestUtils.map("consent", consentsMap), idx);
258259
}
259260

260261
protected static void validateAllConsentRequest(String deviceId, int idx) {
261-
validateConsentRequest(deviceId, idx, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true });
262+
validateConsentRequest(deviceId, idx, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true });
262263
}
263264

264265
// TODO test that makes sure that the consent change request is created correctly

sdk/src/androidTest/java/ly/count/android/sdk/ModuleViewsTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ public void clearFirstViewFlagSessionConsentRemoved() throws JSONException {
13421342
mCountly.views().startView("a", null);
13431343

13441344
// 0 is consent request
1345-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 0, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, true, false, false });
1345+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 0, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false });
13461346
TestUtils.validateRequest(TestUtils.commonDeviceId, TestUtils.map("location", ""), 1);
13471347
// start false because session did not start
13481348
validateView("a", 0.0, 2, 3, false, true, null, vals[0], "");
@@ -1351,12 +1351,12 @@ public void clearFirstViewFlagSessionConsentRemoved() throws JSONException {
13511351
mCountly.consent().giveConsent(new String[] { Countly.CountlyFeatureNames.sessions });
13521352
mCountly.views().startView("b", null);
13531353

1354-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 3, new boolean[] { true, false, false, false, false, false, false, false, false, false, false, false, true, false, false });
1354+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 3, new boolean[] { true, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false });
13551355
validateView("b", 0.0, 4, 5, false, true, null, vals[1], vals[0]);
13561356

13571357
//internal flag should be reset whens session consent is removed
13581358
mCountly.consent().removeConsent(new String[] { Countly.CountlyFeatureNames.sessions });
1359-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 5, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, true, false, false });
1359+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 5, new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false });
13601360

13611361
mCountly.views().startView("c", null);
13621362
// start false because session did not start
@@ -1941,7 +1941,7 @@ public void startView_consentRemoval() throws JSONException {
19411941
validateView("test", 0.0, 4, 6, false, false, TestUtils.map(), "_CLY_", "_CLY_", null);
19421942
validateView("test2", 0.0, 3, 6, false, false, TestUtils.map(), "_CLY_", "_CLY_", null);
19431943
}
1944-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 5, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, false, true, true });
1944+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 5, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true });
19451945

19461946
countly.consent().giveConsent(new String[] { Countly.CountlyFeatureNames.views });
19471947
ModuleConsentTests.validateAllConsentRequest(TestUtils.commonDeviceId, 6);
@@ -1975,7 +1975,7 @@ public void startAutoStoppedView_consentRemoval() throws JSONException {
19751975

19761976
countly.consent().removeConsent(new String[] { Countly.CountlyFeatureNames.views });
19771977
validateView("test2", 0.0, 4, 6, false, false, TestUtils.map(), "_CLY_", "_CLY_", null);
1978-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 5, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, false, true, true });
1978+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 5, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true });
19791979

19801980
countly.consent().giveConsent(new String[] { Countly.CountlyFeatureNames.views });
19811981
ModuleConsentTests.validateAllConsentRequest(TestUtils.commonDeviceId, 6);
@@ -2054,7 +2054,7 @@ public void autoViewTracking_consentRemoval() throws JSONException {
20542054

20552055
countly.consent().removeConsent(new String[] { Countly.CountlyFeatureNames.views });
20562056
validateView(activity2.getClass().getName(), 0.0, 6, 8, false, false, TestUtils.map(), "_CLY_", "_CLY_", null);
2057-
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 7, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, false, true, true });
2057+
ModuleConsentTests.validateConsentRequest(TestUtils.commonDeviceId, 7, new boolean[] { true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true });
20582058

20592059
countly.consent().giveConsent(new String[] { Countly.CountlyFeatureNames.views });
20602060

sdk/src/androidTest/java/ly/count/android/sdk/scSE_SessionsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ protected static Map<String, String> validateSessionUpdateRequest(int idx, Integ
392392
}
393393

394394
private void validateSessionConsentRequest(int idx, boolean consentForSession, String deviceId) {
395-
ModuleConsentTests.validateConsentRequest(deviceId, idx, new boolean[] { consentForSession, false, false, false, false, false, false, false, false, false, false, false, false, false, false });
395+
ModuleConsentTests.validateConsentRequest(deviceId, idx, new boolean[] { consentForSession, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false });
396396
}
397397

398398
private void validateRequest(Map<String, Object> expectedExtras, int idx) {

0 commit comments

Comments
 (0)