Skip to content

Commit d9c5ab4

Browse files
committed
moved context tests around, added AppiumDriverTest
1 parent 3efe96e commit d9c5ab4

File tree

4 files changed

+109
-74
lines changed

4 files changed

+109
-74
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
+Copyright 2014 Appium contributors
3+
+Copyright 2014 Software Freedom Conservancy
4+
+
5+
+Licensed under the Apache License, Version 2.0 (the "License");
6+
+you may not use this file except in compliance with the License.
7+
+You may obtain a copy of the License at
8+
+
9+
+ http://www.apache.org/licenses/LICENSE-2.0
10+
+
11+
+Unless required by applicable law or agreed to in writing, software
12+
+distributed under the License is distributed on an "AS IS" BASIS,
13+
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
+See the License for the specific language governing permissions and
15+
+limitations under the License.
16+
+ */
17+
18+
package io.appium.java_client;
19+
20+
import io.appium.java_client.ios.IOSDriver;
21+
import io.appium.java_client.remote.MobileCapabilityType;
22+
import io.appium.java_client.remote.MobilePlatform;
23+
import org.junit.After;
24+
import org.junit.Before;
25+
import org.junit.Test;
26+
import org.openqa.selenium.ScreenOrientation;
27+
import org.openqa.selenium.html5.Location;
28+
import org.openqa.selenium.remote.DesiredCapabilities;
29+
30+
import java.io.File;
31+
import java.net.URL;
32+
33+
import static org.junit.Assert.assertEquals;
34+
35+
/**
36+
* Test Mobile Driver features
37+
*/
38+
public class AppiumDriverTest {
39+
40+
private AppiumDriver driver;
41+
42+
@Before
43+
public void setup() throws Exception {
44+
File appDir = new File("src/test/java/io/appium/java_client");
45+
File app = new File(appDir, "UICatalog.app.zip");
46+
DesiredCapabilities capabilities = new DesiredCapabilities();
47+
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
48+
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
49+
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
50+
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
51+
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
52+
driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
53+
}
54+
55+
@After
56+
public void tearDown() throws Exception {
57+
driver.quit();
58+
}
59+
60+
@Test
61+
public void resetTest() {
62+
driver.resetApp();
63+
}
64+
65+
@Test
66+
public void setValueTest() {
67+
MobileElement element = (MobileElement)driver.findElementByAccessibilityId("TextFields, Uses of UITextField");
68+
element.click();
69+
element = (MobileElement)driver.findElementByAccessibilityId("Normal");
70+
element.setValue("Grace Hopper");
71+
}
72+
73+
@Test
74+
public void pullFileTest() {
75+
byte[] data = driver.pullFile("Library/AddressBook/AddressBook.sqlitedb");
76+
assert(data.length > 0);
77+
}
78+
79+
//TODO hideKeyboard() test
80+
81+
@Test
82+
public void runAppInBackgroundTest() {
83+
long time = System.currentTimeMillis();
84+
driver.runAppInBackground(4);
85+
long timeAfter = System.currentTimeMillis();
86+
assert(timeAfter - time > 3000);
87+
}
88+
89+
@Test
90+
public void lockTest() {
91+
driver.lockScreen(3);
92+
}
93+
94+
@Test
95+
public void orientationTest() {
96+
assertEquals(ScreenOrientation.PORTRAIT, driver.getOrientation());
97+
driver.rotate(ScreenOrientation.LANDSCAPE);
98+
assertEquals(ScreenOrientation.LANDSCAPE, driver.getOrientation());
99+
}
100+
101+
@Test
102+
public void geolocationTest() {
103+
Location location = new Location(45, 45, 100);
104+
driver.setLocation(location);
105+
}
106+
107+
}

src/test/java/io/appium/java_client/ios/IOSContextTest.java renamed to src/test/java/io/appium/java_client/ContextTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
+limitations under the License.
1616
+ */
1717

18-
package io.appium.java_client.ios;
18+
package io.appium.java_client;
1919

2020
import static org.junit.Assert.assertEquals;
2121
import io.appium.java_client.AppiumDriver;
@@ -34,7 +34,7 @@
3434
/**
3535
* Test context-related features
3636
*/
37-
public class IOSContextTest {
37+
public class ContextTest {
3838

3939
private AppiumDriver driver;
4040

src/test/java/io/appium/java_client/android/AndroidContextTest.java

Lines changed: 0 additions & 72 deletions
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)