Search in sources :

Example 1 with ProxySettingsDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.ProxySettingsDialogFixture in project android by JetBrains.

the class GradlePreSyncTest method testAddProxyConfigureToPropertyFile.

// Verifies that the IDE, during sync, asks the user to copy IDE proxy settings to gradle.properties, if applicable.
// See https://code.google.com/p/android/issues/detail?id=65325
// Similar to {@link com.android.tools.idea.gradle.util.GradlePropertiesTest#testSetProxySettings} test, but also tests the UI
// element that is involved.
@Test
public void testAddProxyConfigureToPropertyFile() throws IOException {
    guiTest.importSimpleApplication();
    String host = "myproxy.test.com";
    int port = 443;
    HttpConfigurable ideSettings = HttpConfigurable.getInstance();
    ideSettings.USE_HTTP_PROXY = true;
    ideSettings.PROXY_HOST = host;
    ideSettings.PROXY_PORT = port;
    ideSettings.PROXY_AUTHENTICATION = true;
    ideSettings.setProxyLogin("test");
    ideSettings.setPlainProxyPassword("testPass");
    ProxySettings ideProxySettings = new ProxySettings(ideSettings);
    GradleProperties properties = new GradleProperties(guiTest.ideFrame().getProject());
    assertNotEquals(ideProxySettings, properties.getHttpProxySettings());
    guiTest.ideFrame().requestProjectSync();
    ProxySettingsDialogFixture proxySettingsDialog = ProxySettingsDialogFixture.find(guiTest.robot());
    proxySettingsDialog.enableHttpsProxy();
    proxySettingsDialog.clickOk();
    properties = new GradleProperties(guiTest.ideFrame().getProject());
    assertEquals(ideProxySettings, properties.getHttpProxySettings());
    ideProxySettings.setProxyType(ProxySettings.HTTPS_PROXY_TYPE);
    assertEquals(ideProxySettings, properties.getHttpsProxySettings());
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
}
Also used : HttpConfigurable(com.intellij.util.net.HttpConfigurable) ProxySettingsDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ProxySettingsDialogFixture) GradleProperties(com.android.tools.idea.gradle.util.GradleProperties) ProxySettings(com.android.tools.idea.gradle.util.ProxySettings) Test(org.junit.Test)

Example 2 with ProxySettingsDialogFixture

use of com.android.tools.idea.tests.gui.framework.fixture.ProxySettingsDialogFixture in project android by JetBrains.

the class GradlePreSyncTest method testDoNotShowProxySettingDialog.

@Test
public void testDoNotShowProxySettingDialog() throws IOException {
    guiTest.importSimpleApplication();
    PropertiesComponent.getInstance(guiTest.ideFrame().getProject()).setValue("show.do.not.copy.http.proxy.settings.to.gradle", "true");
    File gradlePropertiesPath = new File(guiTest.ideFrame().getProjectPath(), "gradle.properties");
    createIfNotExists(gradlePropertiesPath);
    HttpConfigurable ideSettings = HttpConfigurable.getInstance();
    ideSettings.USE_HTTP_PROXY = true;
    ideSettings.PROXY_HOST = "myproxy.test.com";
    ideSettings.PROXY_PORT = 443;
    guiTest.ideFrame().requestProjectSync();
    ProxySettingsDialogFixture proxySettingsDialog = ProxySettingsDialogFixture.find(guiTest.robot());
    proxySettingsDialog.setDoNotShowThisDialog(true);
    proxySettingsDialog.clickOk();
    guiTest.ideFrame().waitForGradleProjectSyncToStart().waitForGradleProjectSyncToFinish();
    // Force a change on the proxy, otherwise the project sync may be ignored.
    ideSettings.PROXY_HOST = "myproxy2.test.com";
    // Verifies that the "Do not show this dialog in the future" does not show up. If it does show up the test will timeout and fail.
    guiTest.ideFrame().requestProjectSync().waitForGradleProjectSyncToFinish();
}
Also used : HttpConfigurable(com.intellij.util.net.HttpConfigurable) ProxySettingsDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ProxySettingsDialogFixture) File(java.io.File) Test(org.junit.Test)

Aggregations

ProxySettingsDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ProxySettingsDialogFixture)2 HttpConfigurable (com.intellij.util.net.HttpConfigurable)2 Test (org.junit.Test)2 GradleProperties (com.android.tools.idea.gradle.util.GradleProperties)1 ProxySettings (com.android.tools.idea.gradle.util.ProxySettings)1 File (java.io.File)1