Browse Source

Sorting crash fixes.

pull/92/head
Abhishek 5 years ago
parent
commit
a8e8fc04fd
  1. 4
      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

4
Clocker/ClockerUITests/ClockerUITests.m

@ -69,13 +69,15 @@
XCUIElement *clockerWindow = self.app.windows[@"Clocker"];
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];
if (rowQueryCount == 0) {
XCTFail("We don't have any timezones added");
return;
}
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 {
XCTFail("There are no timezones.")
return
}
app.windows["Clocker"].tables["TimezoneTableView"].tableRows.firstMatch.click()
@ -62,8 +63,6 @@ class PreferencesTest: XCTestCase {
addAPlace(place: "San Francisco", to: app)
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)
app.windows["Clocker"].checkBoxes["Sort by Time Difference"].click()
@ -99,7 +98,7 @@ class PreferencesTest: XCTestCase {
func testSortingByTimezoneName() {
app.tapMenubarIcon()
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 Label"].exists)
@ -147,8 +146,6 @@ class PreferencesTest: XCTestCase {
addAPlace(place: "Zimbabwe", to: app)
addAPlace(place: "Portland", to: app, shouldSleep: false)
app.windows["Clocker"].checkBoxes["SortButton"].click()
XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists)
var expectedLabels: [String] = []
@ -307,6 +304,7 @@ extension XCUIApplication {
func tapMenubarIcon() {
if menuBars.count < 2 {
XCTFail("Unable to find menubar options")
return
}
statusItems.firstMatch.click()
@ -321,6 +319,7 @@ extension XCTestCase {
if spinnerResult != .completed {
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"?>
<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>
<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"/>
</dependencies>
<objects>
@ -24,7 +24,7 @@
<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"/>
<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">
<rect key="frame" x="0.0" y="0.0" width="319" height="392"/>
<autoresizingMask key="autoresizingMask"/>
@ -46,11 +46,11 @@
</textView>
</subviews>
</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"/>
<autoresizingMask key="autoresizingMask"/>
</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"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
@ -61,7 +61,7 @@
<rect key="frame" x="1" y="1" width="293" height="123"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<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"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="6DY-uj-pMG"/>
@ -72,7 +72,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</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"/>
<constraints>
<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 {
headerView.isHidden = false
additionalSortOptions.isHidden = false
if tableview.subviews.count > 1, let zeroView = notimezoneView, tableview.subviews.contains(zeroView) {
zeroView.removeFromSuperview()
timezoneTableView.enclosingScrollView?.isHidden = false
@ -297,6 +297,7 @@ class PreferencesViewController: ParentViewController {
tableview.addSubview(zeroView)
Logger.log(object: ["Showing Empty View": "YES"], for: "Showing Empty View")
}
additionalSortOptions.isHidden = true
}
private func setupAccessibilityIdentifiers() {

10
Clocker/Preferences/General/SearchDataSource.swift

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

Loading…
Cancel
Save