Browse Source

upgrade legacy calls

AndyScherzinger 8 years ago
parent
commit
9352886c5a
1 changed files with 12 additions and 13 deletions
  1. 12 13
      androidTest/java/com/owncloud/android/uiautomator/InitialTest.java

+ 12 - 13
androidTest/java/com/owncloud/android/uiautomator/InitialTest.java

@@ -18,10 +18,6 @@
 
 
 package com.owncloud.android.uiautomator;
 package com.owncloud.android.uiautomator;
 
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
 import android.content.Context;
 import android.content.Context;
 import android.content.Intent;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager;
@@ -36,6 +32,9 @@ import android.support.test.uiautomator.UiObjectNotFoundException;
 import android.support.test.uiautomator.UiSelector;
 import android.support.test.uiautomator.UiSelector;
 import android.support.test.uiautomator.Until;
 import android.support.test.uiautomator.Until;
 
 
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertThat;
@@ -59,7 +58,6 @@ public class InitialTest {
     public void initializeDevice() {
     public void initializeDevice() {
         // Initialize UiDevice instance
         // Initialize UiDevice instance
         mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
         mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
-
     }
     }
 
 
     @Test
     @Test
@@ -114,7 +112,6 @@ public class InitialTest {
         context.startActivity(intent);
         context.startActivity(intent);
 
 
         clickByText(SETTINGS_DATA_USAGE_OPTION);
         clickByText(SETTINGS_DATA_USAGE_OPTION);
-
     }
     }
 
 
     /**
     /**
@@ -134,24 +131,26 @@ public class InitialTest {
     }
     }
 
 
     /**
     /**
-     * Helper to click on objects that match the content-description text
+     * Helper to click on objects that match the content-description text.
      *
      *
-     * @param text
+     * @param description the description
      * @throws UiObjectNotFoundException
      * @throws UiObjectNotFoundException
      */
      */
-    private void clickByDescription(String text) throws UiObjectNotFoundException {
-        UiObject obj = new UiObject(new UiSelector().description(text));
+    private void clickByDescription(String description) throws UiObjectNotFoundException {
+        UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        UiObject obj = device.findObject(new UiSelector().description(description));
         obj.clickAndWaitForNewWindow();
         obj.clickAndWaitForNewWindow();
     }
     }
 
 
     /**
     /**
-     * Helper to click on object that match the text value
+     * Helper to click on object that match the text value.
      *
      *
-     * @param text
+     * @param text the text
      * @throws UiObjectNotFoundException
      * @throws UiObjectNotFoundException
      */
      */
     private void clickByText(String text) throws UiObjectNotFoundException {
     private void clickByText(String text) throws UiObjectNotFoundException {
-        UiObject obj = new UiObject(new UiSelector().text(text));
+        UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        UiObject obj = device.findObject(new UiSelector().text(text));
         obj.clickAndWaitForNewWindow();
         obj.clickAndWaitForNewWindow();
     }
     }
 }
 }