Add UI Tests for the Test Application

This tests the test application checking for updates, downloading & installing, and relaunching
This commit is contained in:
Zorg committed 2016-02-06 11:32:18 -05:00
1 parent b3dbb5db1f
commit efd94e2de0
7 files changed
+258 -1

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
// UI Test only
INFOPLIST_FILE = UITests/UITests-Info.plist
WRAPPER_EXTENSION = xctest
MACOSX_DEPLOYMENT_TARGET = 10.11
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
TEST_TARGET_NAME = Sparkle Test App
USES_XCTRUNNER = YES
@@ -0,0 +1,4 @@
#include "ConfigUITest.xcconfig"
GCC_GENERATE_TEST_COVERAGE_FILES = NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
@@ -0,0 +1 @@
#include "ConfigUITest.xcconfig"
@@ -0,0 +1 @@
#include "ConfigUITest.xcconfig"
+122 -1
View File
@@ -166,6 +166,8 @@
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; };
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; };
720B16441C66433D006985FB /* UITests-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 720B16421C66433D006985FB /* UITests-Info.plist */; };
720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 720B16431C66433D006985FB /* SUTestApplicationTest.swift */; };
7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; };
721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; };
721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; };
@@ -299,6 +301,13 @@
remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
remoteInfo = Sparkle;
};
726B2B621C645FC900388755 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 61B5F90109C4CEE200B25A18;
remoteInfo = "Sparkle Test App";
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -610,15 +619,22 @@
61F614540E24A12D009F47E7 /* it */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Sparkle.strings; sourceTree = "<group>"; };
61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = "<group>"; };
61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = "<group>"; };
720B16421C66433D006985FB /* UITests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "UITests-Info.plist"; path = "UITests/UITests-Info.plist"; sourceTree = SOURCE_ROOT; };
720B16431C66433D006985FB /* SUTestApplicationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SUTestApplicationTest.swift; path = UITests/SUTestApplicationTest.swift; sourceTree = SOURCE_ROOT; };
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = "<group>"; };
7223E7611AD1AEFF008E3161 /* sais.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sais.c; sourceTree = "<group>"; };
7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = "<group>"; };
7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = "<group>"; };
7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = "<group>"; };
726B2B5D1C645FC900388755 /* UI Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UI Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUOperatingSystem.h; sourceTree = "<group>"; };
726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUOperatingSystem.m; sourceTree = "<group>"; };
7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = "<group>"; };
7275F9C01B5F1F2900B1D19E /* SUFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileManager.m; sourceTree = "<group>"; };
729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = "<group>"; };
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = "<group>"; };
729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestDebug.xcconfig; sourceTree = "<group>"; };
729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestRelease.xcconfig; sourceTree = "<group>"; };
72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUFileManagerTest.swift; sourceTree = "<group>"; };
72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */ = {isa = PBXFileReference; lastKnownFileType = archive.gzip; path = SparkleTestCodeSignApp.tar.gz; sourceTree = "<group>"; };
72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = SparkleTestCodeSignApp.tar; sourceTree = "<group>"; };
@@ -709,6 +725,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
726B2B5A1C645FC900388755 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
8DC2EF560486A6940098B216 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -736,6 +759,7 @@
61B5F90209C4CEE200B25A18 /* Sparkle Test App.app */,
612279D90DB5470200AB99EA /* Sparkle Unit Tests.xctest */,
8DC2EF5B0486A6940098B216 /* Sparkle.framework */,
726B2B5D1C645FC900388755 /* UI Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -750,6 +774,7 @@
14732BB51960ECBA00593899 /* Third Party */,
1420DE391962322200203BB0 /* Documentation */,
FA1941C40D94A6EA00DD942E /* Configurations */,
726B2B5E1C645FC900388755 /* UI Tests */,
0867D69AFE84028FC02AAC07 /* Frameworks */,
034768DFFF38A50411DB9C8B /* Products */,
);
@@ -1082,6 +1107,15 @@
name = "Update Control";
sourceTree = "<group>";
};
726B2B5E1C645FC900388755 /* UI Tests */ = {
isa = PBXGroup;
children = (
720B16421C66433D006985FB /* UITests-Info.plist */,
720B16431C66433D006985FB /* SUTestApplicationTest.swift */,
);
path = "UI Tests";
sourceTree = "<group>";
};
FA1941C40D94A6EA00DD942E /* Configurations */ = {
isa = PBXGroup;
children = (
@@ -1106,6 +1140,10 @@
149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */,
FA3AAF3A1050B273004B3130 /* ConfigUnitTestDebug.xcconfig */,
FA3AAF391050B273004B3130 /* ConfigUnitTestRelease.xcconfig */,
729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */,
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */,
729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */,
729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */,
14732BC91960F70A00593899 /* make-release-package.sh */,
14652F7919A93E5F00959E44 /* set-git-version-info.sh */,
146EC84E19A68CF8004A50C5 /* Sparkle.podspec */,
@@ -1276,6 +1314,24 @@
productReference = 61B5F90209C4CEE200B25A18 /* Sparkle Test App.app */;
productType = "com.apple.product-type.application";
};
726B2B5C1C645FC900388755 /* UI Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 726B2B671C645FC900388755 /* Build configuration list for PBXNativeTarget "UI Tests" */;
buildPhases = (
726B2B591C645FC900388755 /* Sources */,
726B2B5A1C645FC900388755 /* Frameworks */,
726B2B5B1C645FC900388755 /* Resources */,
);
buildRules = (
);
dependencies = (
726B2B631C645FC900388755 /* PBXTargetDependency */,
);
name = "UI Tests";
productName = "UI Tests";
productReference = 726B2B5D1C645FC900388755 /* UI Tests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
8DC2EF4F0486A6940098B216 /* Sparkle */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "Sparkle" */;
@@ -1307,13 +1363,17 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = SU;
LastSwiftUpdateCheck = 0700;
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = "Sparkle Project";
TargetAttributes = {
612279D80DB5470200AB99EA = {
TestTargetID = 8DC2EF4F0486A6940098B216;
};
726B2B5C1C645FC900388755 = {
CreatedOnToolsVersion = 7.2.1;
TestTargetID = 61B5F90109C4CEE200B25A18;
};
};
};
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Sparkle" */;
@@ -1381,6 +1441,7 @@
14732BC51960F69300593899 /* Distribution */,
1420DF491962329200203BB0 /* Documentation */,
1495005F195FB89400BC5B5B /* All */,
726B2B5C1C645FC900388755 /* UI Tests */,
);
};
/* End PBXProject section */
@@ -1428,6 +1489,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
726B2B5B1C645FC900388755 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
720B16441C66433D006985FB /* UITests-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
8DC2EF520486A6940098B216 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1584,6 +1653,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
726B2B591C645FC900388755 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
8DC2EF540486A6940098B216 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1695,6 +1772,11 @@
target = 8DC2EF4F0486A6940098B216 /* Sparkle */;
targetProxy = 61FA528C0E2D9EB200EF58AD /* PBXContainerItemProxy */;
};
726B2B631C645FC900388755 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */;
targetProxy = 726B2B621C645FC900388755 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -2070,6 +2152,35 @@
};
name = Release;
};
726B2B641C645FC900388755 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
726B2B651C645FC900388755 /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Coverage;
};
726B2B661C645FC900388755 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -2163,6 +2274,16 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
726B2B671C645FC900388755 /* Build configuration list for PBXNativeTarget "UI Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
726B2B641C645FC900388755 /* Debug */,
726B2B651C645FC900388755 /* Coverage */,
726B2B661C645FC900388755 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
+95
View File
@@ -0,0 +1,95 @@
//
// SUTestApplicationTest.swift
// Sparkle
//
// Created by Mayur Pawashe on 8/27/15.
// Copyright © 2015 Sparkle Project. All rights reserved.
//
import XCTest
class SUTestApplicationTest: XCTestCase
{
var testApplicationURL: NSURL? = nil
var testApplicationBackupURL: NSURL? = nil
var tempDirectoryURL: NSURL? = nil
override func setUp()
{
super.setUp()
let app = XCUIApplication()
app.launch()
XCTAssertFalse(app.dialogs["alert"].staticTexts["Update succeeded!"].exists, "Update is already installed; please do a clean build")
// We need to grab the app URL so we can back up the app
// When a successful test is over we'll revert the update
// TODO: don't hardcode bundle ID?
let runningApplications = NSRunningApplication.runningApplicationsWithBundleIdentifier("org.sparkle-project.SparkleTestApp")
XCTAssertEqual(runningApplications.count, 1, "More than one running instance of the Test Application is found")
let testApplicationURL = runningApplications[0].bundleURL!
let tempDirectoryURL = try! NSFileManager.defaultManager().URLForDirectory(.ItemReplacementDirectory, inDomain: NSSearchPathDomainMask.UserDomainMask, appropriateForURL: testApplicationURL, create: true)
let testApplicationBackupURL = tempDirectoryURL.URLByAppendingPathComponent(testApplicationURL.lastPathComponent!)
try! NSFileManager.defaultManager().copyItemAtURL(testApplicationURL, toURL: testApplicationBackupURL)
self.testApplicationURL = testApplicationURL
self.testApplicationBackupURL = testApplicationBackupURL
self.tempDirectoryURL = tempDirectoryURL
// when we add more tests we don't want to continue after a failure
// since a test can fail after the new app has been placed in
self.continueAfterFailure = false
}
override func tearDown()
{
// Terminate just in case the app hasn't already quit
XCUIApplication().terminate()
// Revert our update with the original test application
var resultingURL: NSURL? = nil
try! NSFileManager.defaultManager().replaceItemAtURL(self.testApplicationURL!, withItemAtURL: self.testApplicationBackupURL!, backupItemName: nil, options: .UsingNewMetadataOnly, resultingItemURL: &resultingURL)
do {
try NSFileManager.defaultManager().removeItemAtURL(self.tempDirectoryURL!)
} catch let error as NSError {
NSLog("Failed to remove temporary directory \(self.tempDirectoryURL) with error: \(error)")
}
// The URL we get back from NSFileManager should be the same..
XCTAssertEqual(self.testApplicationURL, resultingURL, "Test application was replaced, but at a different location")
super.tearDown()
}
func testRegularUpdate()
{
let app = XCUIApplication()
let menuBarsQuery = app.menuBars
menuBarsQuery.menuBarItems["Sparkle Test App"].click()
// If the update window already showed up automatically, this option will be disabled.
// Even if it's disabled, attempting to click it will do no harm and continue on
menuBarsQuery.menuItems["Check for Updates…"].click()
app.dialogs["SUUpdateAlert"].buttons["Install Update"].click()
app.buttons["Install and Relaunch"].click()
// Our new updated app should be launched now
// Grab another XCUIApplication instance rather than using the old one, just in case
let updatedApp = XCUIApplication()
// Check if we can click the "Update succeeded!" label rather than using the exists property
// Checking the exists property doesn't reload the "cache" and as such the UI tests still would think we are
// referring to the older app. Clicking does force the UI tests to find the new app however
updatedApp.dialogs["alert"].staticTexts["Update succeeded!"].click()
updatedApp.dialogs["alert"].buttons["OK"].click()
}
}
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>