Add additional tests to testplan.

This commit is contained in:
Brent Simmons 2024-09-28 22:48:11 -07:00
parent c6590786ca
commit a3d63b001b
15 changed files with 282 additions and 211 deletions

View File

@ -21,11 +21,58 @@
}
},
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:Modules\/FoundationExtras",
"identifier" : "FoundationExtrasTests",
"name" : "FoundationExtrasTests"
}
},
{
"target" : {
"containerPath" : "container:Modules\/AppKitExtras",
"identifier" : "AppKitExtrasTests",
"name" : "AppKitExtrasTests"
}
},
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:Modules\/Tree",
"identifier" : "TreeTests",
"name" : "TreeTests"
}
},
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:Modules\/Core",
"identifier" : "CoreTests",
"name" : "CoreTests"
}
},
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:Modules\/Web",
"identifier" : "WebTests",
"name" : "WebTests"
}
},
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:Modules\/Feedly",
"identifier" : "FeedlyTests",
"name" : "FeedlyTests"
}
},
{
"target" : {
"containerPath" : "container:NetNewsWire.xcodeproj",
"identifier" : "849C64701ED37A5D003D8FC0",
"name" : "NetNewsWireTests"
}
}
],
"version" : 1

View File

@ -11,7 +11,7 @@ import AppKit
import XCTest
import AppKitExtras
final class NSMenuExtensionsTests: XCTestCase {
@MainActor final class NSMenuExtensionsTests: XCTestCase {
// MARK: - Test addSeparatorIfNeeded

View File

@ -11,6 +11,7 @@ let package = Package(
targets: ["Feedly"]),
],
dependencies: [
.package(path: "../FoundationExtras"),
.package(path: "../Parser"),
.package(path: "../Articles"),
.package(path: "../Secrets"),
@ -22,6 +23,7 @@ let package = Package(
.target(
name: "Feedly",
dependencies: [
"FoundationExtras",
"Parser",
"Articles",
"Secrets",
@ -35,6 +37,9 @@ let package = Package(
),
.testTarget(
name: "FeedlyTests",
dependencies: ["Feedly"]),
dependencies: [
"Feedly",
"FoundationExtras"
]),
]
)

View File

@ -7,6 +7,7 @@
//
import Foundation
import FoundationExtras
import Web
import Secrets

View File

@ -53,7 +53,6 @@
17E0084625941887000C23F0 /* SizeCategories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17E0084525941887000C23F0 /* SizeCategories.swift */; };
27B86EEB25A53AAB00264340 /* Account in Frameworks */ = {isa = PBXBuildFile; productRef = 51BC2F4A24D343A500E90810 /* Account */; };
4679674625E599C100844E8D /* Articles in Frameworks */ = {isa = PBXBuildFile; productRef = 4679674525E599C100844E8D /* Articles */; };
4679674725E599C100844E8D /* Articles in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 4679674525E599C100844E8D /* Articles */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
49F40DF82335B71000552BF4 /* newsfoot.js in Resources */ = {isa = PBXBuildFile; fileRef = 49F40DEF2335B71000552BF4 /* newsfoot.js */; };
49F40DF92335B71000552BF4 /* newsfoot.js in Resources */ = {isa = PBXBuildFile; fileRef = 49F40DEF2335B71000552BF4 /* newsfoot.js */; };
510289CD24519A1D00426DDF /* SelectComboTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 510289CC24519A1D00426DDF /* SelectComboTableViewCell.swift */; };
@ -387,6 +386,8 @@
8456116C2BBD145200507B73 /* Parser in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 8456116A2BBD145200507B73 /* Parser */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
845611712BBD145D00507B73 /* Parser in Frameworks */ = {isa = PBXBuildFile; productRef = 845611702BBD145D00507B73 /* Parser */; };
845611722BBD145D00507B73 /* Parser in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 845611702BBD145D00507B73 /* Parser */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
8457C52E2CA91FED0038F3C0 /* AppKitExtras in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84A059F52C3A4AB20041209B /* AppKitExtras */; };
8457C5302CA920020038F3C0 /* AppKitExtras in Frameworks */ = {isa = PBXBuildFile; productRef = 8457C52F2CA920020038F3C0 /* AppKitExtras */; };
845A29221FC9251E007B49E3 /* SidebarCellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845A29211FC9251E007B49E3 /* SidebarCellLayout.swift */; };
845A29241FC9255E007B49E3 /* SidebarCellAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845A29231FC9255E007B49E3 /* SidebarCellAppearance.swift */; };
845EE7B11FC2366500854A1F /* StarredFeedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845EE7B01FC2366500854A1F /* StarredFeedDelegate.swift */; };
@ -624,7 +625,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
4679674725E599C100844E8D /* Articles in Embed Frameworks */,
8457C52E2CA91FED0038F3C0 /* AppKitExtras in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@ -1326,6 +1327,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8457C5302CA920020038F3C0 /* AppKitExtras in Frameworks */,
4679674625E599C100844E8D /* Articles in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -2670,6 +2672,7 @@
name = NetNewsWireTests;
packageProductDependencies = (
4679674525E599C100844E8D /* Articles */,
8457C52F2CA920020038F3C0 /* AppKitExtras */,
);
productName = NetNewsWireTests;
productReference = 849C64711ED37A5D003D8FC0 /* NetNewsWireTests.xctest */;
@ -4189,6 +4192,10 @@
isa = XCSwiftPackageProductDependency;
productName = Parser;
};
8457C52F2CA920020038F3C0 /* AppKitExtras */ = {
isa = XCSwiftPackageProductDependency;
productName = AppKitExtras;
};
8479ABE22B9E906E00F84C4D /* Database */ = {
isa = XCSwiftPackageProductDependency;
productName = Database;

View File

@ -72,6 +72,18 @@
ReferencedContainer = "container:NetNewsWire.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "MallocStackLogging"
value = ""
isEnabled = "YES">
</AdditionalOption>
<AdditionalOption
key = "PrefersMallocStackLoggingLite"
value = ""
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -12,11 +12,11 @@ import XCTest
@testable import NetNewsWire
class ArticleSorterTests: XCTestCase {
final class ArticleSorterTests: XCTestCase {
// MARK: sortByDate ascending tests
func testSortByDateAscending() {
@MainActor func testSortByDateAscending() {
let now = Date()
let article1 = TestArticle(sortableName: "Susie's Feed", sortableDate: now.addingTimeInterval(-60.0), sortableArticleID: "1", sortableFeedID: "4")
@ -36,7 +36,7 @@ class ArticleSorterTests: XCTestCase {
XCTAssertEqual(sortedArticles.articleAtRow(3), article3)
}
func testSortByDateAscendingWithSameDate() {
@MainActor func testSortByDateAscendingWithSameDate() {
let now = Date()
// Articles with the same date should end up being sorted by their article ID
@ -59,7 +59,7 @@ class ArticleSorterTests: XCTestCase {
XCTAssertEqual(sortedArticles.articleAtRow(4), article3)
}
func testSortByDateAscendingWithGroupByFeed() {
@MainActor func testSortByDateAscendingWithGroupByFeed() {
let now = Date()
let article1 = TestArticle(sortableName: "Phil's Feed", sortableDate: Date(timeInterval: -100.0, since: now), sortableArticleID: "1", sortableFeedID: "1")
@ -94,7 +94,7 @@ class ArticleSorterTests: XCTestCase {
// MARK: sortByDate descending tests
func testSortByDateDescending() {
@MainActor func testSortByDateDescending() {
let now = Date()
let article1 = TestArticle(sortableName: "Susie's Feed", sortableDate: now.addingTimeInterval(-60.0), sortableArticleID: "1", sortableFeedID: "4")
@ -114,7 +114,7 @@ class ArticleSorterTests: XCTestCase {
XCTAssertEqual(sortedArticles.articleAtRow(3), article4)
}
func testSortByDateDescendingWithSameDate() {
@MainActor func testSortByDateDescendingWithSameDate() {
let now = Date()
// Articles with the same date should end up being sorted by their article ID
@ -137,7 +137,7 @@ class ArticleSorterTests: XCTestCase {
XCTAssertEqual(sortedArticles.articleAtRow(4), article5)
}
func testSortByDateDescendingWithGroupByFeed() {
@MainActor func testSortByDateDescendingWithGroupByFeed() {
let now = Date()
let article1 = TestArticle(sortableName: "Phil's Feed", sortableDate: Date(timeInterval: -100.0, since: now), sortableArticleID: "1", sortableFeedID: "1")
@ -172,7 +172,7 @@ class ArticleSorterTests: XCTestCase {
// MARK: Additional group by feed tests
func testGroupByFeedWithCaseInsensitiveFeedNames() {
@MainActor func testGroupByFeedWithCaseInsensitiveFeedNames() {
let now = Date()
let article1 = TestArticle(sortableName: "phil's feed", sortableDate: now, sortableArticleID: "1", sortableFeedID: "1")
@ -197,7 +197,7 @@ class ArticleSorterTests: XCTestCase {
XCTAssertEqual(sortedArticles.articleAtRow(4), article4)
}
func testGroupByFeedWithSameFeedNames() {
@MainActor func testGroupByFeedWithSameFeedNames() {
let now = Date()
// Articles with the same feed name should be sorted by feed ID

View File

@ -8,60 +8,60 @@
import XCTest
class AppleScriptXCTestCase: XCTestCase {
override func setUp() {
super.setUp()
}
override func tearDown() {
super.tearDown()
}
/*
@function doIndividualScript
@param filename -- name of a .applescript (sans extension) in the test bundle's
Resources/TestScripts directory
@brief given a file, loads the script and runs it. Expects a result from running
the script of the form
{test_result:true, script_result:<anything>}
if the test_result is false or is missing, the test fails
@return the value of script_result, if any
*/
func doIndividualScript(filename:String) -> NSAppleEventDescriptor? {
var errorDict: NSDictionary? = nil
let testBundle = Bundle(for: type(of: self))
let url = testBundle.url(forResource:filename, withExtension:"scpt")
guard let testScriptUrl = url else {
XCTFail("Failed Getting script URL")
return nil
}
guard let testScript = NSAppleScript(contentsOf: testScriptUrl, error: &errorDict) else {
print ("error is \(String(describing: errorDict))")
XCTFail("Failed initializing NSAppleScript")
return nil
}
let scriptResult = testScript.executeAndReturnError(&errorDict)
if (errorDict != nil) {
print ("error is \(String(describing: errorDict))")
XCTFail("Failed executing script")
return nil
}
let usrfDictionary = scriptResult.usrfDictionary()
guard let testResult = usrfDictionary["test_result"] else {
XCTFail("test script didn't return test result in usrf")
return nil
}
if (testResult.booleanValue != true) {
print("test_result was \(testResult)")
print("script_result was \(String(describing: usrfDictionary["script_result"]))")
}
XCTAssert(testResult.booleanValue == true, "test_result should be true")
return usrfDictionary["script_result"]
}
}
//class AppleScriptXCTestCase: XCTestCase {
//
// override func setUp() {
// super.setUp()
// }
//
// override func tearDown() {
// super.tearDown()
// }
//
// /*
// @function doIndividualScript
// @param filename -- name of a .applescript (sans extension) in the test bundle's
// Resources/TestScripts directory
// @brief given a file, loads the script and runs it. Expects a result from running
// the script of the form
// {test_result:true, script_result:<anything>}
// if the test_result is false or is missing, the test fails
// @return the value of script_result, if any
// */
// func doIndividualScript(filename:String) -> NSAppleEventDescriptor? {
// var errorDict: NSDictionary? = nil
// let testBundle = Bundle(for: type(of: self))
// let url = testBundle.url(forResource:filename, withExtension:"scpt")
// guard let testScriptUrl = url else {
// XCTFail("Failed Getting script URL")
// return nil
// }
//
// guard let testScript = NSAppleScript(contentsOf: testScriptUrl, error: &errorDict) else {
// print ("error is \(String(describing: errorDict))")
// XCTFail("Failed initializing NSAppleScript")
// return nil
// }
//
// let scriptResult = testScript.executeAndReturnError(&errorDict)
// if (errorDict != nil) {
// print ("error is \(String(describing: errorDict))")
// XCTFail("Failed executing script")
// return nil
// }
//
// let usrfDictionary = scriptResult.usrfDictionary()
// guard let testResult = usrfDictionary["test_result"] else {
// XCTFail("test script didn't return test result in usrf")
// return nil
// }
//
// if (testResult.booleanValue != true) {
// print("test_result was \(testResult)")
// print("script_result was \(String(describing: usrfDictionary["script_result"]))")
// }
//
// XCTAssert(testResult.booleanValue == true, "test_result should be true")
// return usrfDictionary["script_result"]
// }
//}

View File

@ -8,94 +8,94 @@
import XCTest
class ScriptingTests: AppleScriptXCTestCase {
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")
}
func testNameAndUrlOfEveryFeedScript() {
_ = doIndividualScript(filename: "testNameAndUrlOfEveryFeed")
}
func testNameOfEveryFolderScript() {
_ = doIndividualScript(filename: "testNameOfEveryFolder")
}
func testNameOfAuthorsScript() {
_ = doIndividualScript(filename: "testNameOfAuthors")
}
func testFeedExists() {
_ = doIndividualScript(filename: "testFeedExists")
}
func testFeedOPML() {
_ = doIndividualScript(filename: "testFeedOPML")
}
// func testTitleOfArticlesWhoseScript() {
// _ = doIndividualScript(filename: "testTitleOfArticlesWhose")
//class ScriptingTests: AppleScriptXCTestCase {
//
// override func setUp() {
// super.setUp()
// }
//
// func testIterativeCreateAndDeleteScript() {
// _ = doIndividualScriptWithExpectation(filename: "testIterativeCreateAndDeleteFeed")
// override func tearDown() {
// super.tearDown()
// }
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 pieces 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.
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 permission 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.
*/
func disabledTestCurrentArticleScripts() {
doIndividualScriptWithExpectation(filename: "uiScriptingTestSetup")
doIndividualScriptWithExpectation(filename: "establishMainWindowStartingState")
doIndividualScriptWithExpectation(filename: "selectAFeed")
doIndividualScriptWithExpectation(filename: "testCurrentArticleIsNil")
doIndividualScriptWithExpectation(filename: "selectAnArticle")
doIndividualScriptWithExpectation(filename: "testURLsOfCurrentArticle")
}
}
//
//
// /*
// @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")
// }
//
// func testNameAndUrlOfEveryFeedScript() {
// _ = doIndividualScript(filename: "testNameAndUrlOfEveryFeed")
// }
//
// func testNameOfEveryFolderScript() {
// _ = doIndividualScript(filename: "testNameOfEveryFolder")
// }
//
// func testNameOfAuthorsScript() {
// _ = doIndividualScript(filename: "testNameOfAuthors")
// }
//
// func testFeedExists() {
// _ = doIndividualScript(filename: "testFeedExists")
// }
//
// func testFeedOPML() {
// _ = doIndividualScript(filename: "testFeedOPML")
// }
//
//// func testTitleOfArticlesWhoseScript() {
//// _ = doIndividualScript(filename: "testTitleOfArticlesWhose")
//// }
////
//// func testIterativeCreateAndDeleteScript() {
//// _ = doIndividualScriptWithExpectation(filename: "testIterativeCreateAndDeleteFeed")
//// }
//
// 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 pieces 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.
//
// 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 permission 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.
//*/
// func disabledTestCurrentArticleScripts() {
//
// doIndividualScriptWithExpectation(filename: "uiScriptingTestSetup")
// doIndividualScriptWithExpectation(filename: "establishMainWindowStartingState")
// doIndividualScriptWithExpectation(filename: "selectAFeed")
// doIndividualScriptWithExpectation(filename: "testCurrentArticleIsNil")
// doIndividualScriptWithExpectation(filename: "selectAnArticle")
// doIndividualScriptWithExpectation(filename: "testURLsOfCurrentArticle")
// }
//}

View File

@ -1,10 +1,10 @@
-- this script just tests that no error was generated from the script
try
tell application "NetNewsWire"
exists feed 1 of account 1
end tell
on error message
return {test_result:false, script_result:message}
end try
return {test_result:true}
--try
-- tell application "NetNewsWire"
-- exists feed 1 of account 1
-- end tell
--on error message
-- return {test_result:false, script_result:message}
--end try
--
--return {test_result:true}

View File

@ -1,10 +1,10 @@
-- this script just tests that no error was generated from the script
try
tell application "NetNewsWire"
opml representation of feed 1 of account 1
end tell
on error message
return {test_result:false, script_result:message}
end try
return {test_result:true}
--try
-- tell application "NetNewsWire"
-- opml representation of feed 1 of account 1
-- end tell
--on error message
-- return {test_result:false, script_result:message}
--end try
--
--return {test_result:true}

View File

@ -1,10 +1,10 @@
-- this script just tests that no error was generated from the script
try
tell application "NetNewsWire"
{name, url} of every feed of every account
end tell
on error message
return {test_result:false, script_result:message}
end try
return {test_result:true}
--try
-- tell application "NetNewsWire"
-- {name, url} of every feed of every account
-- end tell
--on error message
-- return {test_result:false, script_result:message}
--end try
--
--return {test_result:true}

View File

@ -1,12 +1,12 @@
-- this script just tests that no error was generated from the script
-- and that the returned list is greater than 0
try
tell application "NetNewsWire"
set namesResult to name of every author of every feed of every account
end tell
set test_result to ((count items of namesResult) > 0)
on error message
return {test_result:false, script_result:message}
end try
return {test_result:test_result}
--try
-- tell application "NetNewsWire"
-- set namesResult to name of every author of every feed of every account
-- end tell
-- set test_result to ((count items of namesResult) > 0)
--on error message
-- return {test_result:false, script_result:message}
--end try
--
--return {test_result:test_result}

View File

@ -1,10 +1,10 @@
-- this script just tests that no error was generated from the script
try
tell application "NetNewsWire"
title of every article of feed "Six Colors" where read is true
end tell
on error message
return {test_result:false, script_result:message}
end try
return {test_result:true}
--try
-- tell application "NetNewsWire"
-- title of every article of feed "Six Colors" where read is true
-- end tell
--on error message
-- return {test_result:false, script_result:message}
--end try
--
--return {test_result:true}

View File

@ -11,9 +11,9 @@ import XCTest
@testable import NetNewsWire
class SharingTests: XCTestCase {
final class SharingTests: XCTestCase {
func testSharingSubject() {
@MainActor func testSharingSubject() {
let sharingServiceDelegate = SharingServiceDelegate(nil)
let sharingService = NSSharingService(title: "Chirpy", image: NSImage(size: NSSize.zero), alternateImage: nil, handler: {})
@ -25,7 +25,7 @@ class SharingTests: XCTestCase {
XCTAssertEqual("Immunization", sharingService.subject)
}
func testSharingSubjectMultipleArticles() {
@MainActor func testSharingSubjectMultipleArticles() {
let sharingServiceDelegate = SharingServiceDelegate(nil)
let sharingService = NSSharingService(title: "Chirpy", image: NSImage(size: NSSize.zero), alternateImage: nil, handler: {})
@ -38,7 +38,7 @@ class SharingTests: XCTestCase {
XCTAssertEqual("NetNewsWire Status: Almost Beta, No Algorithms Follow-Up", sharingService.subject)
}
private func article(titled title: String) -> Article {
@MainActor private func article(titled title: String) -> Article {
let articleID = randomID()
return Article(accountID: randomID(),
articleID: articleID,
@ -58,8 +58,7 @@ class SharingTests: XCTestCase {
)
}
private func randomID() -> String {
@MainActor private func randomID() -> String {
return UUID().uuidString
}
}