Skip to content

Commit

Permalink
Fix navigation color and improve snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
twodayslate committed Sep 20, 2022
1 parent 440502f commit 7515ddc
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ec3730.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@
CODE_SIGN_ENTITLEMENTS = ec3730/ec3730.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = C6L3992RFB;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = ec3730/Info.plist;
Expand Down Expand Up @@ -1366,7 +1366,7 @@
CODE_SIGN_ENTITLEMENTS = ec3730/ec3730.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = C6L3992RFB;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = ec3730/Info.plist;
Expand Down
10 changes: 10 additions & 0 deletions ec3730/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if ProcessInfo().arguments.contains("SKIP_ANIMATIONS") {
UIView.setAnimationsEnabled(false)
}

handleUITests()
#endif

UIDevice.current.isBatteryMonitoringEnabled = true
Expand Down Expand Up @@ -80,6 +82,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

func handleUITests() {
if ProcessInfo.processInfo.arguments.contains("UI-Testing") {
UserDefaults.standard.removePersistentDomain(forName: Bundle.main.bundleIdentifier!)
UserDefaults.standard.dictionaryRepresentation().keys.forEach(UserDefaults.standard.removeObject(forKey:))
UserDefaults.standard.synchronize()
}
}

public static var persistantStore: NSPersistentCloudKitContainer? = {
let container = NSPersistentCloudKitContainer(name: "NetUtilsCoreData")
container.loadPersistentStores { _, error in
Expand Down
1 change: 1 addition & 0 deletions ec3730/Controllers/PingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ struct PingSwiftUIViewController: View {
.onDisappear(perform: {
self.pinger?.stopPinging()
})
.background(Color(UIColor.systemGroupedBackground))
.navigationViewStyle(StackNavigationViewStyle())
.environment(\.managedObjectContext, persistenceController.container.viewContext) // NavigationView
}
Expand Down
5 changes: 3 additions & 2 deletions ec3730/Views/Host/HostResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ struct HostResult: View {
}
}
}
.background(Color(UIColor.systemGroupedBackground))
HostBarView(url: group.url, date: group.date)
}.navigationTitle(self.group.url.host ?? "Unknown Host")
}
.background(Color(UIColor.systemGroupedBackground))
.navigationTitle(self.group.url.host ?? "Unknown Host")
}
}
2 changes: 1 addition & 1 deletion ec3730/Views/Host/HostView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct HostView: View {
}
.animation(.default, value: model.sections)
}
.background(Color(UIColor.systemGroupedBackground))
// Fix for the content going above the navigation
// See !92 for more information
.padding(.top, 0.15)
Expand All @@ -61,6 +60,7 @@ struct HostView: View {
cancel: cancel
)
}
.background(Color(UIColor.systemGroupedBackground))
.navigationBarTitle("Host Information", displayMode: .inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing, content: {
Expand Down
2 changes: 1 addition & 1 deletion ec3730/Views/Interface/InterfaceListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ struct InterfaceListView: View {
})
}
}
.background(Color(UIColor.systemGroupedBackground))
.padding(.top, 0.15)
.layoutPriority(1.0)
InterfaceConnectionBarView(model: model)
}
.background(Color(UIColor.systemGroupedBackground))
.onAppear {
model.reload()
}
Expand Down
2 changes: 2 additions & 0 deletions ec3730/Views/Source/SourceCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct SourceCardView: View {
Text("HTML")
.bold()
})
.pickerStyle(.menu)
Spacer()
}

Expand Down Expand Up @@ -112,6 +113,7 @@ struct SourceCardView: View {
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("View Source")
.padding(.top, 0.5)
.background(Color(UIColor.systemGroupedBackground))
.onChange(of: url) { _ in
urlText = url.absoluteString
}
Expand Down
11 changes: 1 addition & 10 deletions ec3730UITests/ec3730UITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class EC3730UITests: XCTestCase {
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
app = XCUIApplication()
app.launchArguments += ["UI-Testing"]
setupSnapshot(app)
app.launch()

Expand All @@ -35,11 +36,9 @@ class EC3730UITests: XCTestCase {
openVC("Host")
app.buttons["Lookup"].tap()
sleep(1)
expandFirstItem()
snapshot("Host")

openVC("Device")
expandFirstItem()
snapshot("Device")

openVC("Ping")
Expand All @@ -55,14 +54,6 @@ class EC3730UITests: XCTestCase {
snapshot("ViewSource")
}

private func expandFirstItem() {
app.scrollViews.otherElements.firstMatch.press(forDuration: 1.1)
let expandButton = app.collectionViews/*@START_MENU_TOKEN@*/ .buttons["Expand"]/*[[".cells.buttons[\"Expand\"]",".buttons[\"Expand\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
if expandButton.isHittable {
expandButton.tap()
}
}

private func openVC(_ key: String) {
// First we try the tab bar
let scrollViewsQuery = app.scrollViews
Expand Down

0 comments on commit 7515ddc

Please sign in to comment.