Skip to content

Commit

Permalink
Remove deprecated method
Browse files Browse the repository at this point in the history
These methods were supposed to be removed in older versions of Robolectric
  • Loading branch information
MGaetan89 committed Feb 16, 2024
1 parent 0307c35 commit 513aff7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 240 deletions.
152 changes: 0 additions & 152 deletions robolectric/src/main/java/org/robolectric/ConfigMerger.java

This file was deleted.

Expand Up @@ -50,7 +50,6 @@
import org.robolectric.pluginapi.config.ConfigurationStrategy;
import org.robolectric.pluginapi.config.ConfigurationStrategy.Configuration;
import org.robolectric.pluginapi.config.GlobalConfigProvider;
import org.robolectric.plugins.HierarchicalConfigurationStrategy.ConfigurationImpl;
import org.robolectric.util.Logger;
import org.robolectric.util.PerfStatsCollector;
import org.robolectric.util.ReflectionHelpers;
Expand All @@ -63,7 +62,11 @@
@SuppressWarnings("NewApi")
public class RobolectricTestRunner extends SandboxTestRunner {

public static final String CONFIG_PROPERTIES = "robolectric.properties";
/**
* @deprecated No longer used. This constant will be removed in a future version of Robolectric.
*/
@Deprecated public static final String CONFIG_PROPERTIES = "robolectric.properties";

private static final Injector DEFAULT_INJECTOR = defaultInjector().build();
private static final Map<ManifestIdentifier, AndroidManifest> appManifestsCache = new HashMap<>();

Expand Down Expand Up @@ -107,7 +110,7 @@ protected RobolectricTestRunner(final Class<?> testClass, Injector injector)
super(testClass, injector);

if (DeprecatedTestRunnerDefaultConfigProvider.globalConfig == null) {
DeprecatedTestRunnerDefaultConfigProvider.globalConfig = buildGlobalConfig();
DeprecatedTestRunnerDefaultConfigProvider.globalConfig = new Config.Builder().build();
}

this.sandboxManager = injector.getInstance(SandboxManager.class);
Expand Down Expand Up @@ -411,66 +414,9 @@ public static AndroidManifest createAndroidManifest(ManifestIdentifier manifestI
manifestIdentifier.getApkFile());
}

/**
* Compute the effective Robolectric configuration for a given test method.
*
* <p>Configuration information is collected from package-level {@code robolectric.properties}
* files and {@link Config} annotations on test classes, superclasses, and methods.
*
* <p>Custom TestRunner subclasses may wish to override this method to provide alternate
* configuration.
*
* @param method the test method
* @return the effective Robolectric configuration for the given test method
* @deprecated Provide an implementation of {@link javax.inject.Provider<Config>} instead. This
* method will be removed in Robolectric 4.3.
* @since 2.0
* @see <a href="http://robolectric.org/migrating/#migrating-to-40">Migration Notes</a> for more
* details.
*/
@Deprecated
public Config getConfig(Method method) {
throw new UnsupportedOperationException();
}

/** Calculate the configuration for a given test method. */
private Configuration getConfiguration(Method method) {
Configuration configuration =
configurationStrategy.getConfig(getTestClass().getJavaClass(), method);

// in case #getConfig(Method) has been overridden...
try {
Config config = getConfig(method);
((ConfigurationImpl) configuration).put(Config.class, config);
} catch (UnsupportedOperationException e) {
// no problem
}

return configuration;
}

/**
* Provides the base Robolectric configuration {@link Config} used for all tests.
*
* <p>Configuration provided for specific packages, test classes, and test method configurations
* will override values provided here.
*
* <p>Custom TestRunner subclasses may wish to override this method to provide alternate
* configuration. Consider using a {@link Config.Builder}.
*
* <p>The default implementation has appropriate values for most use cases.
*
* @return global {@link Config} object
* @deprecated Provide a service implementation of {@link GlobalConfigProvider} instead. This
* method will be removed in Robolectric 4.3.
* @since 3.1.3
* @see <a href="http://robolectric.org/migrating/#migrating-to-40">Migration Notes</a> for more
* details.
*/
@Deprecated
@SuppressWarnings("InlineMeSuggester")
protected Config buildGlobalConfig() {
return new Config.Builder().build();
return configurationStrategy.getConfig(getTestClass().getJavaClass(), method);
}

@AutoService(GlobalConfigProvider.class)
Expand Down
Expand Up @@ -42,11 +42,9 @@
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import org.junit.runners.model.FrameworkMethod;
import org.robolectric.RobolectricTestRunner.RobolectricFrameworkMethod;
import org.robolectric.android.internal.AndroidTestEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Config.Implementation;
import org.robolectric.annotation.experimental.LazyApplication;
import org.robolectric.annotation.experimental.LazyApplication.LazyLoad;
import org.robolectric.config.ConfigurationRegistry;
Expand Down Expand Up @@ -142,20 +140,6 @@ public void testsWithUnsupportedSdkShouldBeIgnored() throws Exception {
.inOrder();
}

@Test
public void supportsOldGetConfigUntil4dot3() throws Exception {
Implementation overriddenConfig = Config.Builder.defaults().build();
List<FrameworkMethod> children = new SingleSdkRobolectricTestRunner(TestWithTwoMethods.class) {
@Override
public Config getConfig(Method method) {
return overriddenConfig;
}
}.getChildren();
Config config = ((RobolectricFrameworkMethod) children.get(0))
.getConfiguration().get(Config.class);
assertThat(config).isSameInstanceAs(overriddenConfig);
}

@Test
public void failureInResetterDoesntBreakAllTests() throws Exception {
RobolectricTestRunner runner =
Expand Down
Expand Up @@ -91,15 +91,4 @@ public ServiceController<T> unbind() {
shadowMainLooper.idleIfPaused();
return this;
}

/**
* @deprecated Use the appropriate builder in {@link org.robolectric.Robolectric} instead.
*
* This method will be removed in Robolectric 3.6.
*/
@Deprecated
public ServiceController<T> withIntent(Intent intent) {
this.intent = intent;
return this;
}
}

0 comments on commit 513aff7

Please sign in to comment.