Skip to content

Commit

Permalink
Add a method for testing - MobileCore.resetSDK() (#241)
Browse files Browse the repository at this point in the history
* add a method for testing - MobileCore.resetSDK()

* update api dump

* address review comments

* fix review comments
  • Loading branch information
yangyansong-adbe authored Oct 7, 2022
1 parent fc2d766 commit 0f66178
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public static void registerExtensions(@NonNull final List<Class<? extends Extens
if (completionCallback != null) {
completionCallback.call(null);
}
} catch (Exception ex) {}
} catch (Exception ex) {
}
}
return null;
});
Expand Down Expand Up @@ -991,4 +992,11 @@ public static boolean dispatchResponseEvent(@NonNull final Event responseEvent,
return true;
}

@VisibleForTesting
static void resetSDK() {
EventHub.Companion.getShared().shutdown();
EventHub.Companion.setShared(new EventHub());
sdkInitializedWithContext.set(false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
package com.adobe.marketing.mobile.integration;
package com.adobe.marketing.mobile;

import com.adobe.marketing.mobile.internal.eventhub.EventHub;

public class EventHubProxy {
public static void resetEventhub() {
EventHub.Companion.setShared(new EventHub());
public class SDKHelper {
public static void resetSDK() {
MobileCore.resetSDK();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import com.adobe.marketing.mobile.Event
import com.adobe.marketing.mobile.LoggingMode
import com.adobe.marketing.mobile.MobileCore
import com.adobe.marketing.mobile.integration.EventHubProxy
import com.adobe.marketing.mobile.SDKHelper
import com.adobe.marketing.mobile.services.HttpConnecting
import com.adobe.marketing.mobile.services.Networking
import com.adobe.marketing.mobile.services.ServiceProvider
Expand Down Expand Up @@ -45,7 +45,7 @@ class SignalExtensionIntegrationTests {
InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as Application

val countDownLatch = CountDownLatch(1)
EventHubProxy.resetEventhub()
SDKHelper.resetSDK()
ServiceProvider.getInstance().networkService = Networking { request, callback ->
var connection: HttpConnecting? = null
with(request.url) {
Expand Down

0 comments on commit 0f66178

Please sign in to comment.