Browse Source

Sorting crash fixes.

pull/92/head
Abhishek 5 years ago
parent
commit
a8e8fc04fd
  1. 2
      Clocker/ClockerUITests/ClockerUITests.m
  2. 9
      Clocker/ClockerUITests/PreferencesTest.swift
  3. 14
      Clocker/Preferences/App Feedback/AppFeedbackWindow.xib
  4. 3
      Clocker/Preferences/General/PreferencesViewController.swift
  5. 10
      Clocker/Preferences/General/SearchDataSource.swift

2
Clocker/ClockerUITests/ClockerUITests.m

@ -70,12 +70,14 @@
if (clockerWindow.tables.count == 0) { if (clockerWindow.tables.count == 0) {
XCTFail("We don't have any timezones added"); XCTFail("We don't have any timezones added");
return;
} }
NSInteger rowQueryCount = [[clockerWindow.tables[@"TimezoneTableView"] tableRows] count]; NSInteger rowQueryCount = [[clockerWindow.tables[@"TimezoneTableView"] tableRows] count];
if (rowQueryCount == 0) { if (rowQueryCount == 0) {
XCTFail("We don't have any timezones added"); XCTFail("We don't have any timezones added");
return;
} }
XCUIElement *currentElement = [[clockerWindow.tables[@"TimezoneTableView"] tableRows] elementBoundByIndex:0]; XCUIElement *currentElement = [[clockerWindow.tables[@"TimezoneTableView"] tableRows] elementBoundByIndex:0];

9
Clocker/ClockerUITests/PreferencesTest.swift

@ -28,6 +28,7 @@ class PreferencesTest: XCTestCase {
if app.tables["TimezoneTableView"].tableRows.count <= 0 { if app.tables["TimezoneTableView"].tableRows.count <= 0 {
XCTFail("There are no timezones.") XCTFail("There are no timezones.")
return
} }
app.windows["Clocker"].tables["TimezoneTableView"].tableRows.firstMatch.click() app.windows["Clocker"].tables["TimezoneTableView"].tableRows.firstMatch.click()
@ -62,8 +63,6 @@ class PreferencesTest: XCTestCase {
addAPlace(place: "San Francisco", to: app) addAPlace(place: "San Francisco", to: app)
addAPlace(place: "Florida", to: app, shouldSleep: false) // Last elements don't need to sleep addAPlace(place: "Florida", to: app, shouldSleep: false) // Last elements don't need to sleep
app.windows["Clocker"].checkBoxes["SortButton"].click()
XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Time Difference"].exists) XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Time Difference"].exists)
app.windows["Clocker"].checkBoxes["Sort by Time Difference"].click() app.windows["Clocker"].checkBoxes["Sort by Time Difference"].click()
@ -99,7 +98,7 @@ class PreferencesTest: XCTestCase {
func testSortingByTimezoneName() { func testSortingByTimezoneName() {
app.tapMenubarIcon() app.tapMenubarIcon()
app.tables["mainTableView"].typeKey(",", modifierFlags: .command) app.tables["mainTableView"].typeKey(",", modifierFlags: .command)
app.windows["Clocker"].checkBoxes["SortButton"].click() // app.windows["Clocker"].checkBoxes["SortButton"].click()
XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Time Difference"].exists) XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Time Difference"].exists)
XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists) XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists)
@ -147,8 +146,6 @@ class PreferencesTest: XCTestCase {
addAPlace(place: "Zimbabwe", to: app) addAPlace(place: "Zimbabwe", to: app)
addAPlace(place: "Portland", to: app, shouldSleep: false) addAPlace(place: "Portland", to: app, shouldSleep: false)
app.windows["Clocker"].checkBoxes["SortButton"].click()
XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists) XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists)
var expectedLabels: [String] = [] var expectedLabels: [String] = []
@ -307,6 +304,7 @@ extension XCUIApplication {
func tapMenubarIcon() { func tapMenubarIcon() {
if menuBars.count < 2 { if menuBars.count < 2 {
XCTFail("Unable to find menubar options") XCTFail("Unable to find menubar options")
return
} }
statusItems.firstMatch.click() statusItems.firstMatch.click()
@ -321,6 +319,7 @@ extension XCTestCase {
if spinnerResult != .completed { if spinnerResult != .completed {
XCTFail("Still seeing Spinner after 25 seconds. Something's wrong") XCTFail("Still seeing Spinner after 25 seconds. Something's wrong")
return
} }
} }

14
Clocker/Preferences/App Feedback/AppFeedbackWindow.xib

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@ -24,7 +24,7 @@
<window title="Clocker Feedback" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5"> <window title="Clocker Feedback" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="437" y="172" width="319" height="392"/> <rect key="contentRect" x="437" y="172" width="319" height="392"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/> <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<view key="contentView" id="se5-gp-TjO"> <view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="319" height="392"/> <rect key="frame" x="0.0" y="0.0" width="319" height="392"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
@ -46,11 +46,11 @@
</textView> </textView>
</subviews> </subviews>
</clipView> </clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="9Ed-AQ-o4N"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="9Ed-AQ-o4N">
<rect key="frame" x="-100" y="-100" width="87" height="18"/> <rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Ls5-gY-fnI"> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Ls5-gY-fnI">
<rect key="frame" x="-100" y="-100" width="15" height="133"/> <rect key="frame" x="-100" y="-100" width="15" height="133"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
@ -61,7 +61,7 @@
<rect key="frame" x="1" y="1" width="293" height="123"/> <rect key="frame" x="1" y="1" width="293" height="123"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="269" translatesAutoresizingMaskIntoConstraints="NO" id="Qzm-kE-Igl" customClass="ClockerTextField" customModule="Clocker" customModuleProvider="target"> <textField verticalHuggingPriority="750" preferredMaxLayoutWidth="269" translatesAutoresizingMaskIntoConstraints="NO" id="Qzm-kE-Igl">
<rect key="frame" x="10" y="88" width="273" height="24"/> <rect key="frame" x="10" y="88" width="273" height="24"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="24" id="6DY-uj-pMG"/> <constraint firstAttribute="height" constant="24" id="6DY-uj-pMG"/>
@ -72,7 +72,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="269" translatesAutoresizingMaskIntoConstraints="NO" id="zlM-Cf-OxV" customClass="ClockerTextField" customModule="Clocker" customModuleProvider="target"> <textField verticalHuggingPriority="750" preferredMaxLayoutWidth="269" translatesAutoresizingMaskIntoConstraints="NO" id="zlM-Cf-OxV">
<rect key="frame" x="10" y="54" width="266" height="24"/> <rect key="frame" x="10" y="54" width="266" height="24"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="24" id="b3M-Sc-y8S"/> <constraint firstAttribute="height" constant="24" id="b3M-Sc-y8S"/>

3
Clocker/Preferences/General/PreferencesViewController.swift

@ -165,7 +165,7 @@ class PreferencesViewController: ParentViewController {
if selectedTimeZones.isEmpty == false { if selectedTimeZones.isEmpty == false {
headerView.isHidden = false headerView.isHidden = false
additionalSortOptions.isHidden = false
if tableview.subviews.count > 1, let zeroView = notimezoneView, tableview.subviews.contains(zeroView) { if tableview.subviews.count > 1, let zeroView = notimezoneView, tableview.subviews.contains(zeroView) {
zeroView.removeFromSuperview() zeroView.removeFromSuperview()
timezoneTableView.enclosingScrollView?.isHidden = false timezoneTableView.enclosingScrollView?.isHidden = false
@ -297,6 +297,7 @@ class PreferencesViewController: ParentViewController {
tableview.addSubview(zeroView) tableview.addSubview(zeroView)
Logger.log(object: ["Showing Empty View": "YES"], for: "Showing Empty View") Logger.log(object: ["Showing Empty View": "YES"], for: "Showing Empty View")
} }
additionalSortOptions.isHidden = true
} }
private func setupAccessibilityIdentifiers() { private func setupAccessibilityIdentifiers() {

10
Clocker/Preferences/General/SearchDataSource.swift

@ -13,6 +13,7 @@ struct TimezoneMetadata {
let timezone: NSTimeZone let timezone: NSTimeZone
let tags: Set<String> let tags: Set<String>
let formattedName: String let formattedName: String
let abbreviation: String
} }
class SearchDataSource: NSObject { class SearchDataSource: NSObject {
@ -53,7 +54,8 @@ class SearchDataSource: NSObject {
let anywhereOnEarth = TimezoneMetadata(timezone: NSTimeZone(abbreviation: "GMT-1200")!, let anywhereOnEarth = TimezoneMetadata(timezone: NSTimeZone(abbreviation: "GMT-1200")!,
tags: ["aoe", "anywhere on earth"], tags: ["aoe", "anywhere on earth"],
formattedName: "Anywhere on Earth") formattedName: "Anywhere on Earth",
abbreviation: "AOE")
timezoneArray.append(anywhereOnEarth) timezoneArray.append(anywhereOnEarth)
for (abbreviation, timezone) in TimeZone.abbreviationDictionary { for (abbreviation, timezone) in TimeZone.abbreviationDictionary {
@ -68,10 +70,10 @@ class SearchDataSource: NSObject {
} }
let timezoneIdentifier = NSTimeZone(name: timezone)! let timezoneIdentifier = NSTimeZone(name: timezone)!
let formattedName = timezone + " (\(abbreviation))"
let timezoneMetadata = TimezoneMetadata(timezone: timezoneIdentifier, let timezoneMetadata = TimezoneMetadata(timezone: timezoneIdentifier,
tags: tags, tags: tags,
formattedName: formattedName) formattedName: timezone,
abbreviation: abbreviation)
timezoneArray.append(timezoneMetadata) timezoneArray.append(timezoneMetadata)
} }
@ -146,7 +148,7 @@ extension SearchDataSource {
return nil return nil
} }
let index = searchField.stringValue.isEmpty ? row - 1 : row let index = searchField.stringValue.isEmpty ? row - 1 : row
message.sourceName.stringValue = datasource[index % datasource.count].formattedName message.sourceName.stringValue = datasource[index % datasource.count].formattedName + " (\(datasource[index % datasource.count].abbreviation))"
return message return message
} }
return nil return nil

Loading…
Cancel
Save