From c8f2239a32157b64505dc323539671e4121517d2 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 14 Jun 2019 01:04:49 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8B=A4=ED=97=98=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=95=8C=EB=A6=BC?= =?UTF-8?q?=EC=97=90=20=EB=B3=84=EB=8F=84=EB=A1=9C=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GureumTests/GureumTests.swift | 2 +- GureumTests/MockInputClient.m | 1 + OSX/UpdateManager.swift | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/GureumTests/GureumTests.swift b/GureumTests/GureumTests.swift index 151e8ebf..5b732451 100644 --- a/GureumTests/GureumTests.swift +++ b/GureumTests/GureumTests.swift @@ -68,7 +68,7 @@ class GureumTests: XCTestCase { XCTFail() return } - let versionInfo = UpdateManager.VersionInfo(data: versionInfoJSON) + let versionInfo = UpdateManager.VersionInfo(data: versionInfoJSON, experimental: true) UpdateManager.shared.notifyUpdate(info: versionInfo) XCTAssertEqual("최신 버전: 1.10.0 현재 버전: \(UpdateManager.bundleVersion ?? "-")\nMojave 대응을 포함한 대형 업데이트", lastNotification.informativeText) XCTAssertEqual(["url": "https://github.com/gureum/gureum/releases/tag/1.10.0"], lastNotification.userInfo as! [String: String]) diff --git a/GureumTests/MockInputClient.m b/GureumTests/MockInputClient.m index cd615766..0e9151fd 100644 --- a/GureumTests/MockInputClient.m +++ b/GureumTests/MockInputClient.m @@ -27,6 +27,7 @@ - (NSString *)selectedString { } - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { + // NSAssert(replacementRange.location == NSNotFound || replacementRange.length != 0, @"-"); [super insertText:string replacementRange:replacementRange]; } diff --git a/OSX/UpdateManager.swift b/OSX/UpdateManager.swift index 09fb0cf8..ea3875d9 100644 --- a/OSX/UpdateManager.swift +++ b/OSX/UpdateManager.swift @@ -16,8 +16,10 @@ class UpdateManager { class VersionInfo { let current: String? = UpdateManager.bundleVersion let data: [String: String] - init(data: [String: String]) { + let experimental: Bool + init(data: [String: String], experimental: Bool) { self.data = data + self.experimental = experimental } var recent: String? { @@ -36,7 +38,7 @@ class UpdateManager { } } - func fetchVersionInfo(from url: URL) -> VersionInfo? { + func fetchVersionInfo(from url: URL, experimental: Bool) -> VersionInfo? { var request = URLRequest(url: url) request.timeoutInterval = 0.5 request.cachePolicy = .reloadIgnoringCacheData @@ -49,17 +51,17 @@ class UpdateManager { guard let info = try? JSONSerialization.jsonObject(with: data as Data) as? [String: String] else { return nil } - return VersionInfo(data: info) + return VersionInfo(data: info, experimental: experimental) } func fetchOfficialVersionInfo() -> VersionInfo? { let url = URL(string: "http://gureum.io/version.json")! - return fetchVersionInfo(from: url) + return fetchVersionInfo(from: url, experimental: false) } func fetchExperimentalVersionInfo() -> VersionInfo? { let url = URL(string: "http://gureum.io/version-experimental.json")! - return fetchVersionInfo(from: url) + return fetchVersionInfo(from: url, experimental: true) } func fetchAutoUpdateVersionInfo() -> VersionInfo? { @@ -75,7 +77,11 @@ class UpdateManager { func notifyUpdate(info: VersionInfo) { let notification = NSUserNotification() - notification.title = "구름 입력기 업데이트 알림" + var title = "구름 입력기 업데이트 알림" + if info.experimental { + title += " (실험 버전)" + } + notification.title = title notification.hasActionButton = true notification.hasReplyButton = false notification.actionButtonTitle = "업데이트"