Search in sources :

Example 1 with MockFileOp

use of com.android.repository.testframework.MockFileOp in project android by JetBrains.

the class PatchInstallerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    ourFileOp = new MockFileOp();
}
Also used : MockFileOp(com.android.repository.testframework.MockFileOp)

Example 2 with MockFileOp

use of com.android.repository.testframework.MockFileOp in project android by JetBrains.

the class AndroidVirtualDeviceTest method testCreateDevice.

public void testCreateDevice() throws Exception {
    MockFileOp fop = new MockFileOp();
    recordPlatform23(fop);
    recordGoogleApisAddon23(fop);
    recordGoogleApisSysImg23(fop);
    fop.recordExistingFile(new File(DeviceArtDescriptor.getBundledDescriptorsFolder(), "nexus_5x"));
    AndroidSdkHandler sdkHandler = new AndroidSdkHandler(new File("/sdk"), new File("/android-home"), fop);
    final AvdManagerConnection connection = new AvdManagerConnection(sdkHandler);
    FakePackage.FakeRemotePackage remotePlatform = new FakePackage.FakeRemotePackage("platforms;android-23");
    RepoFactory factory = AndroidSdkHandler.getRepositoryModule().createLatestFactory();
    DetailsTypes.PlatformDetailsType platformDetailsType = factory.createPlatformDetailsType();
    platformDetailsType.setApiLevel(23);
    remotePlatform.setTypeDetails((TypeDetails) platformDetailsType);
    Map<String, RemotePackage> remotes = Maps.newHashMap();
    remotes.put("platforms;android-23", remotePlatform);
    AndroidVirtualDevice avd = new AndroidVirtualDevice(new ScopedStateStore(ScopedStateStore.Scope.STEP, null, null), remotes, true, fop);
    final AvdInfo avdInfo = avd.createAvd(connection, sdkHandler);
    assertNotNull(avdInfo);
    disposeOnTearDown(() -> connection.deleteAvd(avdInfo));
    assertNotNull(avdInfo);
    Map<String, String> properties = avdInfo.getProperties();
    Map<String, String> referenceMap = getReferenceMap();
    for (Map.Entry<String, String> entry : referenceMap.entrySet()) {
        assertEquals(entry.getKey(), entry.getValue(), FileUtil.toSystemIndependentName(properties.get(entry.getKey())));
    }
    // AVD manager will set some extra properties that we don't care about and that may be system dependant.
    // We do not care about those so we only ensure we have the ones we need.
    File skin = new File(properties.get(AvdManager.AVD_INI_SKIN_PATH));
    assertEquals("nexus_5x", skin.getName());
}
Also used : DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) ScopedStateStore(com.android.tools.idea.wizard.dynamic.ScopedStateStore) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) RepoFactory(com.android.sdklib.repository.meta.RepoFactory) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) MockFileOp(com.android.repository.testframework.MockFileOp) AvdManagerConnection(com.android.tools.idea.avdmanager.AvdManagerConnection) FakePackage(com.android.repository.testframework.FakePackage) File(java.io.File) RemotePackage(com.android.repository.api.RemotePackage) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 3 with MockFileOp

use of com.android.repository.testframework.MockFileOp in project android by JetBrains.

the class RepositoryUrlManagerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    myFileOp = new MockFileOp();
    myRepositoryUrlManager = new RepositoryUrlManager(true);
    mySdkHandler = new AndroidSdkHandler(SDK_DIR, ANDROID_HOME, myFileOp);
    mySdk = Mockito.mock(AndroidSdkData.class);
    Mockito.when(mySdk.getLocation()).thenReturn(SDK_DIR);
    String[] paths = new String[] { // Android repository
    "extras/android/m2repository/com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.aar", "extras/android/m2repository/com/android/support/appcompat-v7/19.0.0/appcompat-v7-19.0.0.aar", "extras/android/m2repository/com/android/support/appcompat-v7/19.0.1/appcompat-v7-19.0.1.aar", "extras/android/m2repository/com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.aar", "extras/android/m2repository/com/android/support/appcompat-v7/20.0.0/appcompat-v7-20.0.0.aar", "extras/android/m2repository/com/android/support/appcompat-v7/21.0.0/appcompat-v7-21.0.0.aar", "extras/android/m2repository/com/android/support/appcompat-v7/21.0.2/appcompat-v7-21.0.2.aar", "extras/android/m2repository/com/android/support/cardview-v7/21.0.0/cardview-v7-21.0.0.aar", "extras/android/m2repository/com/android/support/cardview-v7/21.0.2/cardview-v7-21.0.2.aar", "extras/android/m2repository/com/android/support/support-v13/20.0.0/support-v13-20.0.0.aar", "extras/android/m2repository/com/android/support/support-v13/21.0.0/support-v13-21.0.0.aar", "extras/android/m2repository/com/android/support/support-v13/21.0.2/support-v13-21.0.2.aar", // JARs were used before 19.0.0
    "extras/android/m2repository/com/android/support/support-v4/13.0.0/support-v4-13.0.0.jar", "extras/android/m2repository/com/android/support/support-v4/19.0.1/support-v4-19.0.1.aar", "extras/android/m2repository/com/android/support/support-v4/20.0.0/support-v4-20.0.0.aar", "extras/android/m2repository/com/android/support/support-v4/20.0.0/support-v4-20.0.0-rc1.aar", "extras/android/m2repository/com/android/support/support-v4/21.0.0/support-v4-21.0.0.aar", "extras/android/m2repository/com/android/support/support-v4/21.0.2/support-v4-21.0.2.aar", "extras/android/m2repository/com/android/support/constraint/constraint-layout/1.0.0-alpha7/constraint-layout-1.0.0-alpha7.aar", // Google repository
    "extras/google/m2repository/com/google/android/gms/play-services/3.1.36/play-services-3.1.36.aar", "extras/google/m2repository/com/google/android/gms/play-services/3.1.59/play-services-3.1.59.aar", "extras/google/m2repository/com/google/android/gms/play-services/3.2.25/play-services-3.2.25.aar", "extras/google/m2repository/com/google/android/gms/play-services/3.2.65/play-services-3.2.65.aar", "extras/google/m2repository/com/google/android/gms/play-services/4.0.30/play-services-4.0.30.aar", "extras/google/m2repository/com/google/android/gms/play-services/4.1.32/play-services-4.1.32.aar", "extras/google/m2repository/com/google/android/gms/play-services/4.2.42/play-services-4.2.42.aar", "extras/google/m2repository/com/google/android/gms/play-services/4.3.23/play-services-4.3.23.aar", "extras/google/m2repository/com/google/android/gms/play-services/4.4.52/play-services-4.4.52.aar", "extras/google/m2repository/com/google/android/gms/play-services/5.0.89/play-services-5.0.89.aar", "extras/google/m2repository/com/google/android/gms/play-services/5.2.08/play-services-5.2.08.aar", "extras/google/m2repository/com/google/android/gms/play-services-wearable/5.0.77/play-services-wearable-5.0.77.aar", "extras/google/m2repository/com/google/android/gms/play-services-wearable/6.1.11/play-services-wearable-6.1.11.aar", "extras/google/m2repository/com/google/android/gms/play-services-wearable/6.1.71/play-services-wearable-6.1.71.aar", "extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar", "extras/google/m2repository/com/google/android.wearable/wearable/2.0.0-alpha2/wearable-2.0.0-alpha2.aar" };
    for (String path : paths) {
        myFileOp.createNewFile(new File(SDK_DIR, path));
    }
}
Also used : AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) MockFileOp(com.android.repository.testframework.MockFileOp) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) File(java.io.File)

Example 4 with MockFileOp

use of com.android.repository.testframework.MockFileOp in project android by JetBrains.

the class AvdWizardUtilsTest method createMockSdk.

@NotNull
private static AndroidSdkHandler createMockSdk(String versionString, String path) {
    FakeLocalPackage p = new FakeLocalPackage(path);
    p.setRevision(Revision.parseRevision(versionString));
    RepositoryPackages packages = new RepositoryPackages();
    packages.setLocalPkgInfos(ImmutableList.of(p));
    RepoManager mgr = new FakeRepoManager(null, packages);
    return new AndroidSdkHandler(null, null, new MockFileOp(), mgr);
}
Also used : FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) RepoManager(com.android.repository.api.RepoManager) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) MockFileOp(com.android.repository.testframework.MockFileOp) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with MockFileOp

use of com.android.repository.testframework.MockFileOp in project android by JetBrains.

the class PatchInstallerFactoryTest method setUp.

@Before
public void setUp() {
    myFileOp = new MockFileOp();
    myInstallerFactory = new PatchInstallerFactory();
    myInstallerFactory.setFallbackFactory(new BasicInstallerFactory());
    myRepositoryPackages = new RepositoryPackages();
    File root = new File("/sdk");
    myRepoManager = new FakeRepoManager(root, myRepositoryPackages);
}
Also used : BasicInstallerFactory(com.android.repository.impl.installer.BasicInstallerFactory) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) MockFileOp(com.android.repository.testframework.MockFileOp) File(java.io.File) Before(org.junit.Before)

Aggregations

MockFileOp (com.android.repository.testframework.MockFileOp)5 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)3 File (java.io.File)3 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)2 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)2 RemotePackage (com.android.repository.api.RemotePackage)1 RepoManager (com.android.repository.api.RepoManager)1 BasicInstallerFactory (com.android.repository.impl.installer.BasicInstallerFactory)1 FakePackage (com.android.repository.testframework.FakePackage)1 FakeLocalPackage (com.android.repository.testframework.FakePackage.FakeLocalPackage)1 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)1 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)1 RepoFactory (com.android.sdklib.repository.meta.RepoFactory)1 AvdManagerConnection (com.android.tools.idea.avdmanager.AvdManagerConnection)1 ScopedStateStore (com.android.tools.idea.wizard.dynamic.ScopedStateStore)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)1 NotNull (org.jetbrains.annotations.NotNull)1 Before (org.junit.Before)1