AuthenticatorActivityTest.java 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * ownCloud Android client application
  3. *
  4. * Copyright (C) 2015 ownCloud Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2,
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. package com.owncloud.android.authentication;
  20. import android.content.Context;
  21. import android.content.Intent;
  22. import android.support.test.InstrumentationRegistry;
  23. import android.support.test.rule.ActivityTestRule;
  24. import android.support.test.runner.AndroidJUnit4;
  25. import android.test.suitebuilder.annotation.LargeTest;
  26. import com.owncloud.android.BuildConfig;
  27. import com.owncloud.android.R;
  28. import org.junit.Rule;
  29. import org.junit.Test;
  30. import org.junit.runner.RunWith;
  31. import static android.support.test.espresso.Espresso.onView;
  32. import static android.support.test.espresso.action.ViewActions.click;
  33. import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
  34. import static android.support.test.espresso.action.ViewActions.typeText;
  35. import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
  36. import static android.support.test.espresso.matcher.ViewMatchers.withId;
  37. import static android.support.test.espresso.assertion.ViewAssertions.matches;
  38. import static org.hamcrest.Matchers.not;
  39. @RunWith(AndroidJUnit4.class)
  40. @LargeTest
  41. public class AuthenticatorActivityTest {
  42. public static final String EXTRA_ACTION = "ACTION";
  43. public static final String EXTRA_ACCOUNT = "ACCOUNT";
  44. @Rule
  45. public ActivityTestRule<AuthenticatorActivity> mActivityRule = new ActivityTestRule<AuthenticatorActivity>(
  46. AuthenticatorActivity.class){
  47. @Override
  48. protected Intent getActivityIntent() {
  49. Context targetContext = InstrumentationRegistry.getInstrumentation()
  50. .getTargetContext();
  51. Intent result = new Intent(targetContext, AuthenticatorActivity.class);
  52. result.putExtra(EXTRA_ACTION, "");
  53. result.putExtra(EXTRA_ACCOUNT, "");
  54. return result;
  55. }
  56. };
  57. @Test
  58. public void check_login() {
  59. // Check that login button is disabled
  60. onView(withId(R.id.buttonOK))
  61. .check(matches(not(isEnabled())));
  62. // Type server url
  63. /*
  64. onView(withId(R.id.hostUrlInput))
  65. .perform(typeText(BuildConfig.TEST_SERVER_URL), closeSoftKeyboard());
  66. onView(withId(R.id.account_username)).perform(click());
  67. // Type user
  68. onView(withId(R.id.account_username))
  69. .perform(typeText(BuildConfig.TEST_USER), closeSoftKeyboard());
  70. // Type user pass
  71. onView(withId(R.id.account_password))
  72. .perform(typeText(BuildConfig.TEST_PASSWORD), closeSoftKeyboard());
  73. onView(withId(R.id.buttonOK)).perform(click());
  74. */
  75. // Check that login button is now enabled
  76. onView(withId(R.id.buttonOK)).check(matches(isEnabled()));
  77. }
  78. }