From 49f58cf95500fbbf9c244882963d3c19aa6cc234 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 30 Dec 2019 15:59:49 -0500 Subject: [PATCH] Initial UI testing setup --- .gitmodules | 6 ++ Ambassador | 1 + BlankSlate.xcappdata/AppDataInfo.plist | Bin 0 -> 256 bytes Embassy | 1 + Tusker.xcodeproj/project.pbxproj | 49 +++++++++++++++ .../xcshareddata/xcschemes/Tusker.xcscheme | 27 ++++----- Tusker.xcworkspace/contents.xcworkspacedata | 9 +++ Tusker/Info.plist | 11 ++++ Tusker/LocalData.swift | 14 +++-- .../InstanceSelectorTableViewController.swift | 9 +-- .../Instance Cell/InstanceTableViewCell.xib | 7 ++- TuskerUITests/OnboardingTests.swift | 38 ++++++++++++ TuskerUITests/TuskerUITests.swift | 56 +++++++++++++----- 13 files changed, 185 insertions(+), 43 deletions(-) create mode 160000 Ambassador create mode 100644 BlankSlate.xcappdata/AppDataInfo.plist create mode 160000 Embassy create mode 100644 TuskerUITests/OnboardingTests.swift diff --git a/.gitmodules b/.gitmodules index b39a3e2f..2128c88a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,9 @@ [submodule "Gifu"] path = Gifu url = git://github.com/kaishin/Gifu.git +[submodule "Embassy"] + path = Embassy + url = https://github.com/envoy/Embassy.git +[submodule "Ambassador"] + path = Ambassador + url = https://github.com/envoy/Ambassador.git diff --git a/Ambassador b/Ambassador new file mode 160000 index 00000000..4fe264af --- /dev/null +++ b/Ambassador @@ -0,0 +1 @@ +Subproject commit 4fe264af51e0dd7228486c604750909e368241a7 diff --git a/BlankSlate.xcappdata/AppDataInfo.plist b/BlankSlate.xcappdata/AppDataInfo.plist new file mode 100644 index 0000000000000000000000000000000000000000..5ff068d8d44a4bdd80e257de386cd8ab6c752e85 GIT binary patch literal 256 zcmYc)$jK}&F)+Bs$i&RT%Er#Y$;HhRFCZM@>{^kUTw0Qtl#?2kT2!2wpBES5?2=!e zmy@5E;*waB8ZRIe;q054mzi6d>mLkN6E7futkW+s7pP7!!r8F^Xisut3D6jbn2@uZ zQ)ymGPO4{0YFX<9Gy^Y`hEbOR DLNrP< literal 0 HcmV?d00001 diff --git a/Embassy b/Embassy new file mode 160000 index 00000000..18943610 --- /dev/null +++ b/Embassy @@ -0,0 +1 @@ +Subproject commit 189436100c00efbf5fb2653fe7972a9371db0a91 diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index df771d56..752b7ee2 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -114,6 +114,9 @@ D64F80E2215875CC00BEF393 /* XCBActionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64F80E1215875CC00BEF393 /* XCBActionType.swift */; }; D6538945214D6D7500E3CEFC /* TableViewSwipeActionProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6538944214D6D7500E3CEFC /* TableViewSwipeActionProvider.swift */; }; D65A37F321472F300087646E /* SwiftSoup.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */; }; + D65F613423AEAB6600F3CFD3 /* OnboardingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D65F613323AEAB6600F3CFD3 /* OnboardingTests.swift */; }; + D65F613623AFD65900F3CFD3 /* Ambassador.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D65F613523AFD65900F3CFD3 /* Ambassador.framework */; }; + D65F613823AFD65D00F3CFD3 /* Embassy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D65F613723AFD65D00F3CFD3 /* Embassy.framework */; }; D663625D2135C74800C9CBA2 /* ConversationMainStatusTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D663625C2135C74800C9CBA2 /* ConversationMainStatusTableViewCell.xib */; }; D663625F2135C75500C9CBA2 /* ConversationMainStatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D663625E2135C75500C9CBA2 /* ConversationMainStatusTableViewCell.swift */; }; D663626221360B1900C9CBA2 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = D663626121360B1900C9CBA2 /* Preferences.swift */; }; @@ -391,6 +394,11 @@ D64D0AB02128D9AE005A6F37 /* OnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingViewController.swift; sourceTree = ""; }; D64F80E1215875CC00BEF393 /* XCBActionType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCBActionType.swift; sourceTree = ""; }; D6538944214D6D7500E3CEFC /* TableViewSwipeActionProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewSwipeActionProvider.swift; sourceTree = ""; }; + D65F612D23AE990C00F3CFD3 /* Embassy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Embassy.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D65F613023AE99E000F3CFD3 /* Ambassador.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Ambassador.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D65F613323AEAB6600F3CFD3 /* OnboardingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTests.swift; sourceTree = ""; }; + D65F613523AFD65900F3CFD3 /* Ambassador.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Ambassador.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D65F613723AFD65D00F3CFD3 /* Embassy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Embassy.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D663625C2135C74800C9CBA2 /* ConversationMainStatusTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ConversationMainStatusTableViewCell.xib; sourceTree = ""; }; D663625E2135C75500C9CBA2 /* ConversationMainStatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationMainStatusTableViewCell.swift; sourceTree = ""; }; D663626121360B1900C9CBA2 /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = ""; }; @@ -501,6 +509,7 @@ D6F1F84C2193B56E00F5FE67 /* Cache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cache.swift; sourceTree = ""; }; D6F953EB212519E700CF0F2B /* TimelineTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineTableViewController.swift; sourceTree = ""; }; D6F953EF21251A2900CF0F2B /* MastodonController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonController.swift; sourceTree = ""; }; + D6F98BD523AE951F008A4DAC /* Swifter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Swifter.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -530,6 +539,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D65F613823AFD65D00F3CFD3 /* Embassy.framework in Frameworks */, + D65F613623AFD65900F3CFD3 /* Ambassador.framework in Frameworks */, D60A549221ED515800F1F87C /* GMImagePicker.framework in Frameworks */, D61099C02144B0CC00432DC2 /* Pachyderm.framework in Frameworks */, D65A37F321472F300087646E /* SwiftSoup.framework in Frameworks */, @@ -947,6 +958,11 @@ D65A37F221472F300087646E /* Frameworks */ = { isa = PBXGroup; children = ( + D65F613723AFD65D00F3CFD3 /* Embassy.framework */, + D65F613523AFD65900F3CFD3 /* Ambassador.framework */, + D65F613023AE99E000F3CFD3 /* Ambassador.framework */, + D65F612D23AE990C00F3CFD3 /* Embassy.framework */, + D6F98BD523AE951F008A4DAC /* Swifter.framework */, ); name = Frameworks; sourceTree = ""; @@ -1259,6 +1275,7 @@ isa = PBXGroup; children = ( D6D4DDEF212518A200E1C4BB /* TuskerUITests.swift */, + D65F613323AEAB6600F3CFD3 /* OnboardingTests.swift */, D6D4DDF1212518A200E1C4BB /* Info.plist */, ); path = TuskerUITests; @@ -1371,6 +1388,7 @@ D6D4DDC9212518A000E1C4BB /* Frameworks */, D6D4DDCA212518A000E1C4BB /* Resources */, D6F953E52125197500CF0F2B /* Embed Frameworks */, + D65F612C23AE957600F3CFD3 /* Embed debug-only frameworks */, ); buildRules = ( ); @@ -1415,6 +1433,8 @@ D6D4DDED212518A200E1C4BB /* PBXTargetDependency */, ); name = TuskerUITests; + packageProductDependencies = ( + ); productName = TuskerUITests; productReference = D6D4DDEB212518A200E1C4BB /* TuskerUITests.xctest */; productType = "com.apple.product-type.bundle.ui-testing"; @@ -1472,6 +1492,8 @@ ca, ); mainGroup = D6D4DDC3212518A000E1C4BB; + packageReferences = ( + ); productRefGroup = D6D4DDCD212518A000E1C4BB /* Products */; projectDirPath = ""; projectRoot = ""; @@ -1564,6 +1586,31 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + D65F612C23AE957600F3CFD3 /* Embed debug-only frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${BUILT_PRODUCTS_DIR}/Embassy.framework", + "${BUILT_PRODUCTS_DIR}/Ambassador.framework", + ); + name = "Embed debug-only frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Embassy.framework", + "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Ambassador.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ \"${CONFIGURATION}\" == \"Debug\" ]; then\n echo \"Embedding ${SCRIPT_INPUT_FILE_0}\"\n cp -R $SCRIPT_INPUT_FILE_0 $SCRIPT_OUTPUT_FILE_0\n codesign --force --verbose --sign $EXPANDED_CODE_SIGN_IDENTITY $SCRIPT_OUTPUT_FILE_0\n \n echo \"Embedding ${SCRIPT_INPUT_FILE_1}\"\n cp -R $SCRIPT_INPUT_FILE_1 $SCRIPT_OUTPUT_FILE_1\n codesign --force --verbose --sign $EXPANDED_CODE_SIGN_IDENTITY $SCRIPT_OUTPUT_FILE_1\nelse\n echo \"Skipping embedding debug frameworks\"\nfi\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ D60A548721ED515800F1F87C /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -1764,6 +1811,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D65F613423AEAB6600F3CFD3 /* OnboardingTests.swift in Sources */, D6D4DDF0212518A200E1C4BB /* TuskerUITests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2166,6 +2214,7 @@ "$(inherited)", "@executable_path/Frameworks", ); + OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = net.shadowfacts.Tusker; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme b/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme index 3f67f73b..73646bda 100644 --- a/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme +++ b/Tusker.xcodeproj/xcshareddata/xcschemes/Tusker.xcscheme @@ -1,7 +1,7 @@ + version = "1.7"> @@ -27,6 +27,15 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + @@ -47,6 +56,9 @@ BlueprintName = "TuskerUITests" ReferencedContainer = "container:Tusker.xcodeproj"> + + @@ -59,17 +71,6 @@ - - - - - - - - + + @@ -13,4 +16,10 @@ + + + + diff --git a/Tusker/Info.plist b/Tusker/Info.plist index 5c93739c..5c319b92 100644 --- a/Tusker/Info.plist +++ b/Tusker/Info.plist @@ -2,6 +2,17 @@ + NSAppTransportSecurity + + NSExceptionDomains + + localhost + + NSExceptionAllowsInsecureHTTPLoads + + + + NSUserActivityTypes $(PRODUCT_BUNDLE_IDENTIFIER).activity.show-timeline diff --git a/Tusker/LocalData.swift b/Tusker/LocalData.swift index 26a7ccbb..b74872c4 100644 --- a/Tusker/LocalData.swift +++ b/Tusker/LocalData.swift @@ -12,7 +12,15 @@ class LocalData { static let shared = LocalData() - let defaults = UserDefaults() + let defaults: UserDefaults + + private init() { + if ProcessInfo.processInfo.environment.keys.contains("UI_TESTING") { + defaults = UserDefaults(suiteName: "\(Bundle.main.bundleIdentifier!).uitesting")! + } else { + defaults = UserDefaults() + } + } private let onboardingCompleteKey = "onboardingComplete" var onboardingComplete: Bool { @@ -63,10 +71,6 @@ class LocalData { defaults.set(newValue, forKey: accessTokenKey) } } - - private init() { - } - } extension Notification.Name { diff --git a/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift b/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift index fc174c8e..468ce836 100644 --- a/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift +++ b/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift @@ -75,14 +75,7 @@ class InstanceSelectorTableViewController: UITableViewController { } private func updateSpecificInstance(domain: String) { - var components = URLComponents() - if domain.contains("://") { - let parts = domain.components(separatedBy: "://") - components.scheme = parts[0] - components.host = parts[1] - } else { - components.host = domain - } + var components = URLComponents(string: domain)! if components.scheme != "https" && components.scheme != "http" { components.scheme = "https" } diff --git a/Tusker/Views/Instance Cell/InstanceTableViewCell.xib b/Tusker/Views/Instance Cell/InstanceTableViewCell.xib index c56b2bc9..ed7702f0 100644 --- a/Tusker/Views/Instance Cell/InstanceTableViewCell.xib +++ b/Tusker/Views/Instance Cell/InstanceTableViewCell.xib @@ -1,8 +1,8 @@ - + - + @@ -53,6 +53,9 @@