@Override public void activate() { initManagedSdk(); if (isInstallSupported()) { ManagedCloudSdkUpdateService.getInstance().activate(); } }
@Before public void setUp() throws UnsupportedOsException { // add timer thread to one not to be checked for 'leaks' ThreadTracker.longRunningThreadCreated( ApplicationManager.getApplication(), ManagedCloudSdkUpdateService.SDK_UPDATER_THREAD_NAME); doReturn(mockManagedCloudSdk).when(sdkService).createManagedSdk(); // TODO(ivanporty) remove once test logging system is done via CloudToolsRule sdkService.setLogger(new TestInMemoryLogger()); // make sure everything in test is done synchronously ExecutorService directExecutorService = MoreExecutors.newDirectExecutorService(); ThreadUtil.getInstance().setBackgroundExecutorService(directExecutorService); // run UI updates synchronously doAnswer( invocation -> { ((Runnable) invocation.getArgument(0)).run(); return null; }) .when(sdkService) .invokeOnApplicationUIThread(any()); // replace UI presenter for verifications ManagedCloudSdkServiceUiPresenter.setInstance(mockUiPresenter); when(mockUiPresenter.createProgressListener(any())).thenReturn(mockProgressListener); // init SDK, most tests require initialized state. sdkService.initManagedSdk(); }