2013-10-01 129 views
3

我嘗試爲基於位置的應用程序編寫UIAutomation測試。這裏是我的代碼:UIAutomation在iOS 6中工作,但不在iOS 7中(UIATarget.setLocationWithOptions)

var target = UIATarget.localTarget(); 
var mainWindow = target.frontMostApp().mainWindow(); 

// speed is in meters/sec 
var points = [ 
    {"location":{"latitude":46.783959176435,"longitude":23.542576152853}, "options":{"speed":32.33869934082}}, 
    {"location":{"latitude":46.784235069873,"longitude":23.542993452429}, "options":{"speed":33.44660949707}}, 
    {"location":{"latitude":46.784323173489,"longitude":23.543161503691}, "options":{"speed":33.76908493042}}, 
    {"location":{"latitude":46.784514430638,"longitude":23.54344429169}, "options":{"speed":34.434867858887}}, 
    {"location":{"latitude":46.784609053263,"longitude":23.543600872392}, "options":{"speed":34.673755645752}}, 
    {"location":{"latitude":46.784701914083,"longitude":23.54376055256}, "options":{"speed":34.920608520508}}, 
    {"location":{"latitude":46.784792299278,"longitude":23.543917345257}, "options":{"speed":34.939456939697}}, 
    {"location":{"latitude":46.784869569202,"longitude":23.54409146343}, "options":{"speed":34.837844848633}}, 
    {"location":{"latitude":46.784959115698,"longitude":23.544272081608}, "options":{"speed":34.80908203125}}, 
    {"location":{"latitude":46.785085476228,"longitude":23.544603009802}, "options":{"speed":34.722270965576}}, 
    {"location":{"latitude":46.785085476228,"longitude":23.544603009802}, "options":{"speed":0.0}} 
]; 

var driveDetectionStarted; 
for (var i = 0; i < points.length; i++){ 
    target.setLocationWithOptions(points[i].location,points[i].options); // send location update 
    target.delay(0.2); // sleep until next location update 
} 

target.delay(1); 
if (mainWindow.staticTexts()[0].value() == "Updates Received") { 
    driveDetectionStarted = true; 
} 
if (driveDetectionStarted) { 
    UIALogger.logPass("Location updates received as expected."); 
} else { 
    UIALogger.logFail("Location updates logic failed."); 
} 

應用必須接收位置更新,如果一切正常,那麼它會顯示一個UILabel與「更新收到」文本。此測試正在iOS 6上進行,但我沒有在iOS 7上收到位置更新信息。我在設備上嘗試過,因爲target.delay(x)方法在模擬器中無法與新的xcode一起使用。 (我測試過了,它在舊的xcode版本中工作。)

任何人都可以幫助我在iOS 7上運行測試嗎?有沒有人面臨同樣的問題? (我打算寫更復雜的測試,但如果我沒有收到位置更新,那麼我簡單的不能移動的。)

謝謝

+0

我向蘋果提交了一個雷達。 http://openradar.appspot.com/radar?id=4964878712307712 - 雷達#17838015 - 仍然不適用於iOS 8 beta版。 – jmoody

+0

在8.0 SDK的Beta(3,4,5)上試用它,它不起作用。令人沮喪。 –

回答

2

我在這裏有同樣的問題。 setLocation()和setLocationWithOptions()方法在iOS 7上不起作用。在文檔中,UIATarget的所有方法(在iOS 7之前可用)都缺失,修訂歷史中沒有這些更改的條目。

相關問題