forked from element-hq/element-x-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from tchapgouv/14-xcodegen-enhance-architectur…
…e-to-facilitate-rebase Enhance xcodegen project files
- Loading branch information
Showing
13 changed files
with
262 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"configurations" : [ | ||
{ | ||
"id" : "991CB720-B4D2-4F1F-BB8A-A2C1A717F529", | ||
"name" : "TchapX", | ||
"options" : { | ||
|
||
} | ||
} | ||
], | ||
"defaultOptions" : { | ||
"defaultTestExecutionTimeAllowance" : 60, | ||
"environmentVariableEntries" : [ | ||
{ | ||
"key" : "IS_RUNNING_UNIT_TESTS", | ||
"value" : "1" | ||
} | ||
], | ||
"testExecutionOrdering" : "random", | ||
"testTimeoutsEnabled" : true | ||
}, | ||
"testTargets" : [ | ||
{ | ||
"target" : { | ||
"containerPath" : "container:TchapX.xcodeproj", | ||
"identifier" : "E156D99C308BC583D03697F6", | ||
"name" : "Tchap-Production" | ||
} | ||
} | ||
], | ||
"version" : 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: TchapX-UnitTests | ||
|
||
schemes: | ||
UnitTests: | ||
analyze: | ||
config: Debug | ||
archive: | ||
config: Release | ||
build: | ||
targets: | ||
TchapX-UnitTests: all | ||
profile: | ||
config: Release | ||
run: | ||
config: Debug | ||
disableMainThreadChecker: false | ||
test: | ||
config: Debug | ||
disableMainThreadChecker: false | ||
gatherCoverageData: true | ||
coverageTargets: | ||
- TchapX-Development | ||
testPlans: | ||
- path: UnitTests.xctestplan | ||
# Don't set it as defaultPlan to avoid conflict with ElementX defaultPlan. | ||
defaultPlan: false | ||
|
||
targets: | ||
TchapX-UnitTests: | ||
type: bundle.unit-test | ||
platform: iOS | ||
|
||
dependencies: | ||
- target: TchapX-Development | ||
|
||
info: | ||
path: ../development/SupportingFiles/Info.plist | ||
|
||
settings: | ||
base: | ||
PRODUCT_NAME: TchapX-UnitTests | ||
PRODUCT_BUNDLE_IDENTIFIER: ${BASE_BUNDLE_IDENTIFIER}.unit.tests | ||
debug: | ||
release: | ||
|
||
sources: | ||
# - path: ../../ElementX/Sources/Other/InfoPlistReader.swift | ||
# - path: ../../Tools/Scripts/Templates/SimpleScreenExample/Tests/Unit | ||
- path: ../main/UnitTests/Sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
TchapX/main/Sources/Other/Helpers/MatrixIdFromString.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2024. DINUM | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE | ||
* OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
// | ||
// MatrixIdFromString.swift | ||
// Tchap X | ||
// | ||
// Created by Nicolas Buquet on 03/10/2024. | ||
// Copyright © 2024 Tchap. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct MatrixIdFromString { | ||
private var mxIdString: String | ||
|
||
init(_ mxIdString: String) { | ||
self.mxIdString = mxIdString | ||
} | ||
|
||
/// Get the homeserver name of a matrix identifier. | ||
/// | ||
/// - Returns: the homeserver name, if any, `nil` otherwise. | ||
/// | ||
/// The identifier type may be any matrix identifier type: user id, room id, ... | ||
/// | ||
/// For example in case of "@jean-philippe.martin-modernisation.fr:matrix.test.org", this will return "matrix.test.org". | ||
/// | ||
/// In case of "!AAAAAAA:matrix.test.org", this will return "matrix.test.org". | ||
/// | ||
var homeServerName: Substring { | ||
guard let splitIndex = mxIdString.firstIndex(of: ":") else { | ||
return "" | ||
} | ||
return mxIdString[mxIdString.index(after: splitIndex)...] | ||
} | ||
|
||
/// Get the Tchap display name of the homeserver mentioned in a matrix identifier. | ||
/// | ||
/// - Returns: the Tchap display name of the homeserver. | ||
/// | ||
/// The identifier type may be any matrix identifier type: user id, room id, ... | ||
/// | ||
/// The returned name is capitalized. | ||
/// | ||
/// The Tchap HS display name is the component mentioned before the suffix "tchap.gouv.fr" | ||
/// | ||
/// For example in case of "@jean-philippe.martin-modernisation.fr:name1.tchap.gouv.fr", this will return "Name1". | ||
/// in case of "@jean-philippe.martin-modernisation.fr:agent.name2.tchap.gouv.fr", this will return "Name2". | ||
|
||
var homeServerDisplayName: Substring { | ||
var homeserverName = homeServerName | ||
if homeserverName.hasSuffix("tchap.gouv.fr") { | ||
let homeserverNameComponents = homeserverName.split(separator: ".") | ||
if homeserverNameComponents.count >= 4 { | ||
homeserverName = homeserverNameComponents[homeserverNameComponents.count - 4] | ||
} | ||
} | ||
return homeserverName.prefix(1).localizedCapitalized + homeserverName.localizedLowercase.dropFirst() | ||
} | ||
|
||
/// Tells whether a homeserver name corresponds to an external server or not. | ||
/// | ||
/// - Returns: true if external. | ||
|
||
var isExternalTchapServer: Bool { | ||
mxIdString.isEmpty || mxIdString.hasPrefix("e.") || mxIdString.hasPrefix("agent.externe.") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// UserDisplayName.swift | ||
// TchapX | ||
// | ||
// Created by Nicolas Buquet on 09/10/2024. | ||
// Copyright © 2024 Tchap. All rights reserved. | ||
// | ||
|
||
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// UserDisplayNaneTests.swift | ||
// IntegrationTests | ||
// | ||
// Created by Nicolas Buquet on 09/10/2024. | ||
// Copyright © 2024 Tchap. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
@testable import TchapX_Development | ||
|
||
final class UserDisplayNaneTests: XCTestCase { | ||
func testUserName() { | ||
XCTAssertEqual(MatrixIdFromString("@jean-philippe.martin-modernisation.fr:matrix.test.org").homeServerName, "matrix.test.org") | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// String.swift | ||
// UnitTests | ||
// | ||
// Created by Nicolas Buquet on 03/10/2024. | ||
// Copyright © 2024 Tchap. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
final class String: XCTestCase { | ||
|
||
override func setUpWithError() throws { | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
} | ||
|
||
func testExample() throws { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
// Any test you write for XCTest can be annotated as throws and async. | ||
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. | ||
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. | ||
} | ||
|
||
func testPerformanceExample() throws { | ||
// This is an example of a performance test case. | ||
self.measure { | ||
// Put the code you want to measure the time of here. | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters