Browse Source

Tests fix!

pull/92/head
Abhishek 5 years ago
parent
commit
4aceea91b8
  1. 5
      Clocker/Clocker/en.lproj/Localizable.strings
  2. 5
      Clocker/Clocker/hi.lproj/Localizable.strings
  3. 5
      Clocker/ClockerUITests/FloatingWindowTests.swift
  4. 18
      Clocker/ClockerUITests/OnboardingTests.swift
  5. 9
      Clocker/ClockerUITests/PreferencesTest.swift
  6. 3
      Clocker/Onboarding/OnboardingWelcomeViewController.swift

5
Clocker/Clocker/en.lproj/Localizable.strings

@ -149,3 +149,8 @@
"You're offline, maybe?" = "You're offline, maybe?"; "You're offline, maybe?" = "You're offline, maybe?";
"Try again, maybe?" = "Try again, maybe?"; "Try again, maybe?" = "Try again, maybe?";
"The Internet connection appears to be offline." = "The Internet connection appears to be offline."; "The Internet connection appears to be offline." = "The Internet connection appears to be offline.";
// UI Tests
"New Zealand" = "New Zealand";
"Florida" = "Florida";
"San Francisco" = "San Francisco";

5
Clocker/Clocker/hi.lproj/Localizable.strings

@ -66,3 +66,8 @@
// Appearance Tab // Appearance Tab
"Panel Theme" = "परकटन"; "Panel Theme" = "परकटन";
// UI Tests
"New Zealand" = "नड";
"Florida" = "फि";
"San Francisco" = "सन फि";

5
Clocker/ClockerUITests/FloatingWindowTests.swift

@ -5,10 +5,7 @@ import XCTest
extension String { extension String {
func localizedString() -> String { func localizedString() -> String {
let bundle = Bundle(for: AboutUsTests.self) let bundle = Bundle(for: AboutUsTests.self)
let deviceLanguage = Locale.preferredLanguages.first return NSLocalizedString(self, bundle: bundle, comment: "")
let localizationBundle = Bundle(path: bundle.path(forResource: deviceLanguage,
ofType: "lproj")!)
return NSLocalizedString(self, bundle: localizationBundle!, comment: "")
} }
} }

18
Clocker/ClockerUITests/OnboardingTests.swift

@ -98,8 +98,8 @@ class OnboardingTests: XCTestCase {
let onboardingWindow = app.windows["OnboardingWindow"] let onboardingWindow = app.windows["OnboardingWindow"]
// Tests static texts // Tests static texts
XCTAssertTrue(onboardingWindow.staticTexts["Clocker"].exists, "Static text Clocker was unexpectedly missing") XCTAssertTrue(onboardingWindow.staticTexts["CFBundleDisplayName".localizedString()].exists, "Static text Clocker was unexpectedly missing")
XCTAssertTrue(onboardingWindow.staticTexts["It only takes 3 steps to set up Clocker."].exists, "Accessory label's static text was unexpectedly wrong.") XCTAssertTrue(onboardingWindow.staticTexts["It only takes 3 steps to set up Clocker.".localizedString()].exists, "Accessory label's static text was unexpectedly wrong.")
let button = onboardingWindow.buttons["Forward"] let button = onboardingWindow.buttons["Forward"]
@ -112,10 +112,10 @@ class OnboardingTests: XCTestCase {
private func permissionsControllerTests() { private func permissionsControllerTests() {
let onboardingWindow = app.windows["OnboardingWindow"] let onboardingWindow = app.windows["OnboardingWindow"]
XCTAssertTrue(onboardingWindow.staticTexts["Permissions"].exists, "Header label's static text was unexpectedly wrong.") XCTAssertTrue(onboardingWindow.staticTexts["Permissions".localizedString()].exists, "Header label's static text was unexpectedly wrong.")
XCTAssertTrue(onboardingWindow.staticTexts["These can be configured later in System Preferences."].exists, "Onboarding Info label's static text was unexpectedly wrong.") XCTAssertTrue(onboardingWindow.staticTexts["Later Config Description".localizedString()].exists, "Onboarding Info label's static text was unexpectedly wrong.")
XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Continue", "Forward button title's was unexpectedly wrong") XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Continue".localizedString(), "Forward button title's was unexpectedly wrong")
XCTAssertTrue(onboardingWindow.buttons["Backward"].exists, "Back button was unexpectedly missing") XCTAssertTrue(onboardingWindow.buttons["Backward"].exists, "Back button was unexpectedly missing")
XCTAssertFalse(onboardingWindow.buttons["Alternate"].exists, "Alternate button was unexpectedly present.") XCTAssertFalse(onboardingWindow.buttons["Alternate"].exists, "Alternate button was unexpectedly present.")
} }
@ -126,17 +126,17 @@ class OnboardingTests: XCTestCase {
XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Open Clocker At Login", "Forward button title's was unexpectedly wrong") XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Open Clocker At Login", "Forward button title's was unexpectedly wrong")
XCTAssertTrue(onboardingWindow.buttons["Alternate"].title == "Don't Open", "Alternate button title's was unexpectedly wrong") XCTAssertTrue(onboardingWindow.buttons["Alternate"].title == "Don't Open", "Alternate button title's was unexpectedly wrong")
XCTAssertTrue(onboardingWindow.staticTexts["Launch at Login"].exists, "Header label's static text was unexpectedly wrong.") XCTAssertTrue(onboardingWindow.staticTexts["Launch at Login".localizedString()].exists, "Header label's static text was unexpectedly wrong.")
XCTAssertTrue(onboardingWindow.staticTexts["Should Clocker open automatically on startup?"].exists, "Accessory label's static text was unexpectedly wrong.") XCTAssertTrue(onboardingWindow.staticTexts["Should Clocker open automatically on startup?".localizedString()].exists, "Accessory label's static text was unexpectedly wrong.")
} }
private func searchControllerTests() { private func searchControllerTests() {
let onboardingWindow = app.windows["OnboardingWindow"] let onboardingWindow = app.windows["OnboardingWindow"]
XCTAssertFalse(onboardingWindow.buttons["Alternate"].exists, "Alternate button was unexpectedly present.") XCTAssertFalse(onboardingWindow.buttons["Alternate"].exists, "Alternate button was unexpectedly present.")
XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Continue", "Forward button title's was unexpectedly wrong") XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Continue".localizedString(), "Forward button title's was unexpectedly wrong")
XCTAssertTrue(onboardingWindow.staticTexts["Quick Add Locations"].exists, "Header label's static text was unexpectedly wrong.") XCTAssertTrue(onboardingWindow.staticTexts["Quick Add Locations".localizedString()].exists, "Header label's static text was unexpectedly wrong.")
XCTAssertTrue(onboardingWindow.staticTexts["More search options in Clocker Preferences."].exists, "Accessory label's static text was unexpectedly wrong.") XCTAssertTrue(onboardingWindow.staticTexts["More search options in Clocker Preferences."].exists, "Accessory label's static text was unexpectedly wrong.")
} }

9
Clocker/ClockerUITests/PreferencesTest.swift

@ -76,7 +76,10 @@ class PreferencesTest: XCTestCase {
} }
} }
XCTAssertEqual(actualLabels, ["New Zealand", "Florida", "San Francisco"]) XCTAssertEqual(actualLabels,
["New Zealand".localizedString(),
"Florida".localizedString(),
"San Francisco".localizedString()])
app.windows["Clocker"].checkBoxes["Sort by Time Difference".localizedString()].click() app.windows["Clocker"].checkBoxes["Sort by Time Difference".localizedString()].click()
@ -89,7 +92,9 @@ class PreferencesTest: XCTestCase {
} }
} }
XCTAssertEqual(actualReversedLabels, ["San Francisco", "Florida", "New Zealand"]) XCTAssertEqual(actualReversedLabels, ["San Francisco".localizedString(),
"Florida".localizedString(),
"New Zealand".localizedString()])
addAPlace(place: "Omaha", to: app) addAPlace(place: "Omaha", to: app)
addAPlace(place: "Mumbai", to: app) addAPlace(place: "Mumbai", to: app)

3
Clocker/Onboarding/OnboardingWelcomeViewController.swift

@ -12,8 +12,7 @@ class OnboardingWelcomeViewController: NSViewController {
} }
private func setup() { private func setup() {
appLabel.stringValue = NSLocalizedString("CFBundleDisplayName", appLabel.stringValue = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ?? "Clocker"
comment: "App Name")
accessoryLabel.stringValue = NSLocalizedString("It only takes 3 steps to set up Clocker.", accessoryLabel.stringValue = NSLocalizedString("It only takes 3 steps to set up Clocker.",
comment: "App Setup Description") comment: "App Setup Description")

Loading…
Cancel
Save