From fd177bf7dc4499af603c0008273f90a8090a03dc Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 15 Sep 2019 14:24:41 -0700 Subject: [PATCH] Adding a UI interruptions handler. --- Clocker/Clocker/en.lproj/Localizable.strings | 6 +++--- Clocker/ClockerUITests/FloatingWindowTests.swift | 11 ++++++++++- Clocker/ClockerUITests/PreferencesTest.swift | 6 +++++- .../General/PreferencesViewController.swift | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Clocker/Clocker/en.lproj/Localizable.strings b/Clocker/Clocker/en.lproj/Localizable.strings index 61efd45..97f4e00 100644 --- a/Clocker/Clocker/en.lproj/Localizable.strings +++ b/Clocker/Clocker/en.lproj/Localizable.strings @@ -46,9 +46,9 @@ "Sort by Name" = "Sort by Name"; "Sort by Label" = "Sort by Label"; "Search Field Placeholder" = "Enter a city, state or country name"; -"No Timezone Selected Error Message" = "Please select a timezone!"; -"Max Timezones Selected Error Message" = "Maximum 100 timezones allowed!"; -"Max Search Characters Error Message" = "Only 50 characters allowed!"; +"No Timezone Selected" = "Please select a timezone!"; +"Max Timezones Selected" = "Maximum 100 timezones allowed!"; +"Max Search Characters" = "Only 50 characters allowed!"; "Add Button Title" = "Add"; "Close Button Title" = "Close"; diff --git a/Clocker/ClockerUITests/FloatingWindowTests.swift b/Clocker/ClockerUITests/FloatingWindowTests.swift index 4f825fe..d53324e 100644 --- a/Clocker/ClockerUITests/FloatingWindowTests.swift +++ b/Clocker/ClockerUITests/FloatingWindowTests.swift @@ -76,6 +76,15 @@ class FloatingWindowTests: XCTestCase { let remindersCheckbox = app.checkBoxes["ReminderCheckbox"] remindersCheckbox.click() + addUIInterruptionMonitor(withDescription: "Reminders Access") { (alert) -> Bool in + let alertButton = alert.buttons["OK"] + if alertButton.exists { + alertButton.tap() + return true + } + return false + } + app.buttons["SaveButton"].click() app.tapMenubarIcon() @@ -109,7 +118,7 @@ class FloatingWindowTests: XCTestCase { } app.buttons["FloatingPreferences"].click() - app.windows["Clocker"].toolbars.buttons["General"].click() + app.windows["Clocker"].toolbars.buttons["Preferences"].click() let menubarDisplayQuery = app.tables.checkBoxes.matching(NSPredicate(format: "value == 1", "")) let menubarDisplayQueryCount = menubarDisplayQuery.count diff --git a/Clocker/ClockerUITests/PreferencesTest.swift b/Clocker/ClockerUITests/PreferencesTest.swift index eb95563..e7616ea 100644 --- a/Clocker/ClockerUITests/PreferencesTest.swift +++ b/Clocker/ClockerUITests/PreferencesTest.swift @@ -144,6 +144,8 @@ class PreferencesTest: XCTestCase { addAPlace(place: "Aurangabad", to: app) addAPlace(place: "Zimbabwe", to: app) addAPlace(place: "Portland", to: app, shouldSleep: false) + addAPlace(place: "Asia/Kolkata", to: app) + addAPlace(place: "Anywhere on Earth", to: app, shouldSleep: false) XCTAssertTrue(app.windows["Clocker"].checkBoxes["Sort by Label"].exists) @@ -176,7 +178,9 @@ class PreferencesTest: XCTestCase { deleteAPlace(place: "Aurangabad", for: app) deleteAPlace(place: "Zimbabwe", for: app) - deleteAPlace(place: "Portland", for: app, shouldSleep: false) + deleteAPlace(place: "Portland", for: app) + deleteAPlace(place: "Asia/Kolkata", for: app) + deleteAPlace(place: "Anywhere on Earth", for: app, shouldSleep: false) } func testSortingTimezonesByCustomLabel() { diff --git a/Clocker/Preferences/General/PreferencesViewController.swift b/Clocker/Preferences/General/PreferencesViewController.swift index 7fb3076..6903295 100644 --- a/Clocker/Preferences/General/PreferencesViewController.swift +++ b/Clocker/Preferences/General/PreferencesViewController.swift @@ -7,7 +7,7 @@ struct PreferencesConstants { comment: "Message shown when the user taps on Add without selecting a timezone") static let maxTimezonesErrorMessage = NSLocalizedString("Max Timezones Selected", comment: "Max Timezones Error Message") - static let maxCharactersAllowed = NSLocalizedString("Max Search Characters Error Message", + static let maxCharactersAllowed = NSLocalizedString("Max Search Characters", comment: "Max Character Count Allowed Error Message") static let noInternetConnectivityError = "You're offline, maybe?" static let tryAgainMessage = "Try again, maybe?"