Skip to content

Commit 3d08ea7

Browse files
committed
add UITests Target
1 parent 0933d43 commit 3d08ea7

File tree

9 files changed

+286
-4
lines changed

9 files changed

+286
-4
lines changed

FeedMe.xcodeproj/project.pbxproj

+192
Large diffs are not rendered by default.

FeedMe.xcodeproj/xcuserdata/airing.xcuserdatad/xcschemes/FeedMe.xcscheme

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "9D2DCF9B1C57590600B39CD5"
36+
BuildableName = "FeedMeUITests.xctest"
37+
BlueprintName = "FeedMeUITests"
38+
ReferencedContainer = "container:FeedMe.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
3141
</Testables>
3242
<MacroExpansion>
3343
<BuildableReference

FeedMe.xcodeproj/xcuserdata/airing.xcuserdatad/xcschemes/xcschememanagement.plist

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
</dict>
1313
<key>SuppressBuildableAutocreation</key>
1414
<dict>
15+
<key>9D2DCF9B1C57590600B39CD5</key>
16+
<dict>
17+
<key>primary</key>
18+
<true/>
19+
</dict>
1520
<key>9D7793891C49EC410084D151</key>
1621
<dict>
1722
<key>primary</key>

FeedMe/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
111111
let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
112112
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("SingleViewCoreData.sqlite")
113113

114-
114+
print("sqlite: \(url)")
115115

116116
var failureReason = "There was an error creating or loading the application's saved data."
117117
do {

FeedMe/Base.lproj/Main.storyboard

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder=" Phone Number" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="V3M-Gn-Fkj">
8989
<rect key="frame" x="-25" y="-30" width="97" height="30"/>
9090
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
91+
<accessibility key="accessibilityConfiguration" identifier="username"/>
9192
<constraints>
9293
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="40" id="8Zo-qt-oN5"/>
9394
<constraint firstAttribute="height" constant="40" id="EKE-AE-uJI"/>
@@ -117,6 +118,7 @@
117118
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder=" Password" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="hmC-fB-jg9">
118119
<rect key="frame" x="-25" y="-30" width="97" height="30"/>
119120
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
121+
<accessibility key="accessibilityConfiguration" identifier="password"/>
120122
<constraints>
121123
<constraint firstAttribute="width" constant="199" id="Ba5-XF-5aF"/>
122124
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="40" id="EJP-zn-XSg"/>
@@ -452,6 +454,7 @@
452454
</variation>
453455
</view>
454456
<connections>
457+
<outlet property="imgLogo" destination="Sww-2h-CWi" id="a1e-ii-5oW"/>
455458
<outlet property="txtUserAccount" destination="V3M-Gn-Fkj" id="B3G-9Z-ppg"/>
456459
<outlet property="txtUserPassword" destination="hmC-fB-jg9" id="lQw-Ej-oZQ"/>
457460
<segue destination="Q5l-3o-fch" kind="show" identifier="LoginSegue" id="9ey-wI-MuE"/>

FeedMe/LoginViewController.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class LoginViewController: UIViewController, UITextFieldDelegate {
4949

5050
@IBOutlet weak var txtUserAccount: UITextField!
5151
@IBOutlet weak var txtUserPassword: UITextField!
52+
@IBOutlet weak var imgLogo: UIImageView!
5253

5354
@IBAction func login() {
5455

@@ -125,6 +126,8 @@ class LoginViewController: UIViewController, UITextFieldDelegate {
125126
override func viewDidLoad() {
126127
super.viewDidLoad()
127128

129+
self.imgLogo.center.x -= self.view.bounds.width
130+
128131
//获取管理的数据上下文 对象
129132
let app = UIApplication.sharedApplication().delegate as! AppDelegate
130133
let context = app.managedObjectContext
@@ -144,14 +147,14 @@ class LoginViewController: UIViewController, UITextFieldDelegate {
144147
fatalError("不能保存:\(error)")
145148
}
146149

147-
148150
}
149151

150152
override func didReceiveMemoryWarning() {
151153
super.didReceiveMemoryWarning()
152154
// Dispose of any resources that can be recreated.
153155
}
154156

157+
155158
func textFieldShouldReturn(textField: UITextField) -> Bool {
156159
textField.resignFirstResponder()
157160
return true

FeedMe/RegisterViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RegisterViewController: UIViewController, UITextFieldDelegate {
1717
"userId": 3
1818
*/
1919

20-
struct User : JSONJoy {
20+
struct Json : JSONJoy {
2121
var result: Int?
2222
var userId: Int?
2323
init() {
@@ -54,7 +54,7 @@ class RegisterViewController: UIViewController, UITextFieldDelegate {
5454
let params: Dictionary<String,AnyObject> = ["userAccount": self.txtUserPhone.text!, "userPassword": self.txtPassword.text!]
5555
request.POST("http://121.42.195.113/feedme/register.action", parameters: params, completionHandler: {(response: HTTPResponse) in
5656
if let res: AnyObject = response.responseObject {
57-
let json = User(JSONDecoder(res))
57+
let json = Json(JSONDecoder(res))
5858
print("result: \(json.result!)")
5959
if (json.result! == 1) {
6060
print("注册成功")

FeedMeUITests/FeedMeUITests.swift

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// FeedMeUITests.swift
3+
// FeedMeUITests
4+
//
5+
// Created by Airing on 16/1/26.
6+
// Copyright © 2016年 Airing. All rights reserved.
7+
//
8+
9+
import XCTest
10+
11+
class FeedMeUITests: XCTestCase {
12+
13+
override func setUp() {
14+
super.setUp()
15+
16+
// Put setup code here. This method is called before the invocation of each test method in the class.
17+
18+
// In UI tests it is usually best to stop immediately when a failure occurs.
19+
continueAfterFailure = false
20+
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
21+
XCUIApplication().launch()
22+
23+
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
24+
}
25+
26+
override func tearDown() {
27+
// Put teardown code here. This method is called after the invocation of each test method in the class.
28+
super.tearDown()
29+
}
30+
31+
func testExample() {
32+
33+
let app = XCUIApplication()
34+
let usernameTextField = app.textFields["username"]
35+
usernameTextField.tap()
36+
usernameTextField.typeText("18154099269")
37+
38+
let passwordSecureTextField = app.secureTextFields["password"]
39+
passwordSecureTextField.tap()
40+
passwordSecureTextField.typeText("123456")
41+
app.buttons["Login"].tap()
42+
43+
}
44+
45+
}

FeedMeUITests/Info.plist

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
</dict>
24+
</plist>

0 commit comments

Comments
 (0)