StudioSdkInstallerUtil { @VisibleForTesting @NotNull InstallerFactory doCreateInstallerFactory(@NotNull AndroidSdkHandler sdkHandler) { InstallerFactory factory; InstallerFactory basicFactory = new BasicInstallerFactory(); if (mySettingsController.getDisableSdkPatches()) { factory = basicFactory; } else { factory = new PatchInstallerFactory(); factory.setFallbackFactory(basicFactory); } factory.setListenerFactory(new StudioSdkInstallListenerFactory(sdkHandler)); return factory; } private  StudioSdkInstallerUtil(); @VisibleForTesting  StudioSdkInstallerUtil(@NotNull SettingsController settingsController); @NotNull static InstallerFactory createInstallerFactory(@NotNull AndroidSdkHandler sdkHandler);  }
@Test public void testSdkPatchesDisablementAndCorrectInstallerFactory() { FakeSettingsController settingsController = new FakeSettingsController(true); settingsController.setDisableSdkPatches(false); StudioSdkInstallerUtil sdkInstallerUtil = new StudioSdkInstallerUtil(settingsController); MockFileOp fop = new MockFileOp(); final AndroidSdkHandler sdkHandler = new AndroidSdkHandler(null, new File("/sdk"), fop); InstallerFactory factory = sdkInstallerUtil.doCreateInstallerFactory(sdkHandler); assertThat(factory).isInstanceOf(PatchInstallerFactory.class); settingsController.setDisableSdkPatches(true); factory = sdkInstallerUtil.doCreateInstallerFactory(sdkHandler); assertThat(factory).isInstanceOf(BasicInstallerFactory.class); }