AuthenticatorActivityTest.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. //
  20. //package com.owncloud.android.authentication;
  21. //
  22. //import android.app.Activity;
  23. //import android.content.Context;
  24. //import android.content.Intent;
  25. //import android.os.Bundle;
  26. //import android.os.RemoteException;
  27. //import android.support.test.InstrumentationRegistry;
  28. //import android.support.test.rule.ActivityTestRule;
  29. //import android.support.test.runner.AndroidJUnit4;
  30. //import android.support.test.uiautomator.UiDevice;
  31. //import android.test.suitebuilder.annotation.LargeTest;
  32. //
  33. //import com.owncloud.android.R;
  34. //
  35. //import org.junit.Before;
  36. //import org.junit.Rule;
  37. //import org.junit.Test;
  38. //import org.junit.runner.RunWith;
  39. //
  40. //import java.lang.reflect.Field;
  41. //
  42. //import static android.support.test.espresso.Espresso.onView;
  43. //import static android.support.test.espresso.action.ViewActions.click;
  44. //import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
  45. //import static android.support.test.espresso.action.ViewActions.typeText;
  46. //import static android.support.test.espresso.assertion.ViewAssertions.matches;
  47. //import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
  48. //import static android.support.test.espresso.matcher.ViewMatchers.withId;
  49. //import static org.hamcrest.Matchers.not;
  50. //import static org.junit.Assert.assertTrue;
  51. //
  52. //@RunWith(AndroidJUnit4.class)
  53. //@LargeTest
  54. //public class AuthenticatorActivityTest {
  55. //
  56. // public static final String EXTRA_ACTION = "ACTION";
  57. // public static final String EXTRA_ACCOUNT = "ACCOUNT";
  58. //
  59. // private static final int WAIT_LOGIN = 5000;
  60. //
  61. // private static final String ERROR_MESSAGE = "Activity not finished";
  62. // private static final String RESULT_CODE = "mResultCode";
  63. //
  64. //
  65. // @Rule
  66. // public ActivityTestRule<AuthenticatorActivity> mActivityRule = new ActivityTestRule<AuthenticatorActivity>(
  67. // AuthenticatorActivity.class){
  68. // @Override
  69. // protected Intent getActivityIntent() {
  70. //
  71. // Context targetContext = InstrumentationRegistry.getInstrumentation()
  72. // .getTargetContext();
  73. // Intent result = new Intent(targetContext, AuthenticatorActivity.class);
  74. // result.putExtra(EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);
  75. // result.putExtra(EXTRA_ACCOUNT, "");
  76. // return result;
  77. // }
  78. // };
  79. //
  80. // @Before
  81. // public void init(){
  82. // UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
  83. // /*Point[] coordinates = new Point[4];
  84. // coordinates[0] = new Point(248, 1020);
  85. // coordinates[1] = new Point(248, 429);
  86. // coordinates[2] = new Point(796, 1020);
  87. // coordinates[3] = new Point(796, 429);*/
  88. // try {
  89. // if (!uiDevice.isScreenOn()) {
  90. // uiDevice.wakeUp();
  91. // //uiDevice.swipe(coordinates, 10);
  92. // }
  93. // } catch (RemoteException e) {
  94. // e.printStackTrace();
  95. // }
  96. // }
  97. //
  98. // @Test
  99. // public void checkLogin()
  100. // throws InterruptedException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
  101. // Bundle arguments = InstrumentationRegistry.getArguments();
  102. //
  103. // // Get values passed
  104. // String testUser = arguments.getString("TEST_USER");
  105. // String testPassword = arguments.getString("TEST_PASSWORD");
  106. // String testServerURL = arguments.getString("TEST_SERVER_URL");
  107. //
  108. // // Check that login button is disabled
  109. // onView(withId(R.id.buttonOK))
  110. // .check(matches(not(isEnabled())));
  111. //
  112. // // Type server url
  113. // onView(withId(R.id.hostUrlInput))
  114. // .perform(typeText(testServerURL), closeSoftKeyboard());
  115. // onView(withId(R.id.account_username)).perform(click());
  116. //
  117. // // Type user
  118. // onView(withId(R.id.account_username))
  119. // .perform(typeText(testUser), closeSoftKeyboard());
  120. //
  121. // // Type user pass
  122. // onView(withId(R.id.account_password))
  123. // .perform(typeText(testPassword), closeSoftKeyboard());
  124. // onView(withId(R.id.buttonOK)).perform(click());
  125. //
  126. // // Check that the Activity ends after clicking
  127. //
  128. // Thread.sleep(WAIT_LOGIN);
  129. // Field f = Activity.class.getDeclaredField(RESULT_CODE);
  130. // f.setAccessible(true);
  131. // int mResultCode = f.getInt(mActivityRule.getActivity());
  132. //
  133. // assertTrue(ERROR_MESSAGE, mResultCode == Activity.RESULT_OK);
  134. //
  135. // }
  136. //}