This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4892: Add back the @jvmoverloads to the Glean SDK public API r=Dexterp37 a=Dexterp37 This additionally adds unit testing in Java to make sure we're not regressing this again. Note: this restores the annotations that were removed by #4620 Co-authored-by: Alessio Placitelli <[email protected]>
- Loading branch information
Showing
3 changed files
with
63 additions
and
2 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
52 changes: 52 additions & 0 deletions
52
...nents/service/glean/src/test/java/mozilla/components/service/glean/GleanFromJavaTest.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,52 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package mozilla.components.service.glean; | ||
|
||
import androidx.test.core.app.ApplicationProvider; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import mozilla.components.service.glean.config.Configuration; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
public class GleanFromJavaTest { | ||
// The only purpose of these tests is to make sure the Glean API is | ||
// callable from Java. If something goes wrong, it should complain about missing | ||
// methods at build-time. | ||
|
||
@Test | ||
public void testInitGleanWithDefaults() { | ||
Glean.INSTANCE.initialize(ApplicationProvider.getApplicationContext()); | ||
} | ||
|
||
@Test | ||
public void testInitGleanWithConfiguration() { | ||
Configuration config = | ||
new Configuration(Configuration.DEFAULT_TELEMETRY_ENDPOINT, "test-channel"); | ||
Glean.INSTANCE.initialize(ApplicationProvider.getApplicationContext(), config); | ||
} | ||
|
||
@Test | ||
public void testGleanExperimentsAPIWithDefaults() { | ||
Glean.INSTANCE.setExperimentActive("test-exp-id-1", "test-branch-1"); | ||
} | ||
|
||
@Test | ||
public void testGleanExperimentsAPIWithOptional() { | ||
Map<String, String> experimentProperties = new HashMap<>(); | ||
experimentProperties.put("test-prop1", "test-prop-result1"); | ||
|
||
Glean.INSTANCE.setExperimentActive( | ||
"test-exp-id-1", | ||
"test-branch-1", | ||
experimentProperties | ||
); | ||
} | ||
} |