2018-01-08 00:13:10 +01:00
|
|
|
//
|
|
|
|
// ScriptingTests.swift
|
2018-08-29 07:18:24 +02:00
|
|
|
// NetNewsWireTests
|
2018-01-08 00:13:10 +01:00
|
|
|
//
|
|
|
|
// Created by Olof Hellman on 1/7/18.
|
|
|
|
// Copyright © 2018 Olof Hellman. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
|
2018-02-11 10:20:30 +01:00
|
|
|
class ScriptingTests: AppleScriptXCTestCase {
|
2018-01-08 00:13:10 +01:00
|
|
|
|
|
|
|
override func setUp() {
|
|
|
|
super.setUp()
|
|
|
|
}
|
|
|
|
|
|
|
|
override func tearDown() {
|
|
|
|
super.tearDown()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@function testGenericScript
|
|
|
|
@brief An example of how a script can be run as part of an XCTest
|
|
|
|
the applescript returns
|
|
|
|
{test_result:true, script_result:"Geoducks!"}
|
|
|
|
doIndividualScript() verifies the test_result portion
|
|
|
|
this code verifies the script_result portion
|
|
|
|
*/
|
|
|
|
func testGenericScript() {
|
|
|
|
let scriptResult = doIndividualScript(filename: "testGenericScript")
|
|
|
|
XCTAssert( scriptResult?.stringValue == "Geoducks!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func testGetUrlScript() {
|
|
|
|
_ = doIndividualScript(filename: "testGetURL")
|
|
|
|
}
|
2018-01-11 09:51:25 +01:00
|
|
|
|
|
|
|
func testNameAndUrlOfEveryFeedScript() {
|
|
|
|
_ = doIndividualScript(filename: "testNameAndUrlOfEveryFeed")
|
|
|
|
}
|
|
|
|
|
|
|
|
func testNameOfEveryFolderScript() {
|
|
|
|
_ = doIndividualScript(filename: "testNameOfEveryFolder")
|
|
|
|
}
|
2018-01-20 07:31:17 +01:00
|
|
|
|
|
|
|
func testNameOfAuthorsScript() {
|
|
|
|
_ = doIndividualScript(filename: "testNameOfAuthors")
|
|
|
|
}
|
2018-01-20 07:49:01 +01:00
|
|
|
|
2018-04-26 06:40:50 +02:00
|
|
|
func testFeedExists() {
|
|
|
|
_ = doIndividualScript(filename: "testFeedExists")
|
|
|
|
}
|
|
|
|
|
2018-01-24 09:27:56 +01:00
|
|
|
func testFeedOPML() {
|
2018-01-20 07:49:01 +01:00
|
|
|
_ = doIndividualScript(filename: "testFeedOPML")
|
|
|
|
}
|
2018-01-08 00:13:10 +01:00
|
|
|
|
2019-08-02 07:51:03 +02:00
|
|
|
// func testTitleOfArticlesWhoseScript() {
|
|
|
|
// _ = doIndividualScript(filename: "testTitleOfArticlesWhose")
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func testIterativeCreateAndDeleteScript() {
|
|
|
|
// _ = doIndividualScriptWithExpectation(filename: "testIterativeCreateAndDeleteFeed")
|
|
|
|
// }
|
2018-03-05 03:43:29 +01:00
|
|
|
|
2018-02-11 10:20:30 +01:00
|
|
|
func doIndividualScriptWithExpectation(filename:String) {
|
|
|
|
let queue = DispatchQueue(label:"testQueue")
|
|
|
|
let scriptExpectation = self.expectation(description: filename+"expectation")
|
|
|
|
queue.async {
|
|
|
|
_ = self.doIndividualScript(filename:filename)
|
|
|
|
scriptExpectation.fulfill()
|
|
|
|
}
|
|
|
|
self.wait(for:[scriptExpectation], timeout:60)
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
@function testCurrentArticleScripts
|
|
|
|
@brief the pices of the test are broken up into smaller pieces because of the
|
|
|
|
way events are delivered to the app -- I tried one single script with all the
|
|
|
|
actions and the keystrokes aren't delivered to the app right away, so the ui
|
|
|
|
isn't updated in time for 'current article' to be set. But, breaking them up
|
|
|
|
in this way seems to work.
|
2019-07-31 07:43:54 +02:00
|
|
|
|
|
|
|
July 30, 2019: There's an issue where in order for a script to send keystrokes,
|
|
|
|
The app has to be allowed to interact with the SystemEvents.app in
|
|
|
|
System Preferences -> Security & Privacy -> Privacy -> Accessibility
|
|
|
|
and this premission needs to be renewed every time the app is recompiled unless
|
|
|
|
the app is codesigned. Until we figure out how to get around this limitation,
|
|
|
|
this test is disabled.
|
2018-02-11 10:20:30 +01:00
|
|
|
*/
|
2019-07-31 07:43:54 +02:00
|
|
|
func disabledTestCurrentArticleScripts() {
|
|
|
|
|
2018-02-11 10:20:30 +01:00
|
|
|
doIndividualScriptWithExpectation(filename: "uiScriptingTestSetup")
|
|
|
|
doIndividualScriptWithExpectation(filename: "establishMainWindowStartingState")
|
|
|
|
doIndividualScriptWithExpectation(filename: "selectAFeed")
|
|
|
|
doIndividualScriptWithExpectation(filename: "testCurrentArticleIsNil")
|
|
|
|
doIndividualScriptWithExpectation(filename: "selectAnArticle")
|
|
|
|
doIndividualScriptWithExpectation(filename: "testURLsOfCurrentArticle")
|
|
|
|
}
|
2018-01-08 00:13:10 +01:00
|
|
|
}
|
2018-02-11 10:20:30 +01:00
|
|
|
|
|
|
|
|