-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add raw tokens and semantic tokens for opacity (#29)
THis commit updates when needed the values of raw tokens and semenatic tokens for opacity. It brings also unit tests for theme overriding and raw tokens relationships. Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 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
51 changes: 51 additions & 0 deletions
51
OUDS/Core/Themes/Tests/Shared/ThemeOverrideOfOpacitySemanticTokens.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,51 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import XCTest | ||
@testable import OUDSThemesShared | ||
|
||
/// The architecture of _OUDS iOS_ _Swift package_ library is based on _object oriented paradigm_ and overriding of classes. | ||
/// In factn the `OUDSTheme` object is a class, which can be seens as an _asbtract class_, exposing through its extensions and protocols _opacity semantic tokens_. | ||
/// These semantic tokens should be overriden by subclass like the `OrangeTheme` default theme. | ||
/// **These tests checks if any _opacity semantic tokens_ can be surcharged by a child theme** | ||
final class ThemeOverrideOfOpacitySemanticTokens: XCTestCase { | ||
|
||
private var abstractTheme: OUDSTheme! | ||
private var inheritedTheme: OUDSTheme! | ||
|
||
override func setUp() async throws { | ||
abstractTheme = OUDSTheme() | ||
inheritedTheme = MockTheme() | ||
} | ||
|
||
/// Test overriding of opacity width semantic tokens | ||
func testInheritedThemeCanOverrideOpacitySemanticTokens() throws { | ||
XCTAssertNotEqual(inheritedTheme.opacityTransparent, abstractTheme.opacityTransparent) | ||
XCTAssertTrue(inheritedTheme.opacityTransparent == MockTheme.mockThemeOpacityRawToken) | ||
|
||
XCTAssertNotEqual(inheritedTheme.opacityWeaker, abstractTheme.opacityWeaker) | ||
XCTAssertTrue(inheritedTheme.opacityWeaker == MockTheme.mockThemeOpacityRawToken) | ||
|
||
XCTAssertNotEqual(inheritedTheme.opacityWeak, abstractTheme.opacityWeak) | ||
XCTAssertTrue(inheritedTheme.opacityWeak == MockTheme.mockThemeOpacityRawToken) | ||
|
||
XCTAssertNotEqual(inheritedTheme.opacityMedum, abstractTheme.opacityMedum) | ||
XCTAssertTrue(inheritedTheme.opacityMedum == MockTheme.mockThemeOpacityRawToken) | ||
|
||
XCTAssertNotEqual(inheritedTheme.opacityEmphasis, abstractTheme.opacityEmphasis) | ||
XCTAssertTrue(inheritedTheme.opacityEmphasis == MockTheme.mockThemeOpacityRawToken) | ||
|
||
XCTAssertNotEqual(inheritedTheme.opacityOpaque, abstractTheme.opacityOpaque) | ||
XCTAssertTrue(inheritedTheme.opacityOpaque == MockTheme.mockThemeOpacityRawToken) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
OUDS/Core/Themes/Tests/Shared/_/MockTheme+OpacitySemanticTokens.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,28 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import Foundation | ||
import OUDSTokensRaw | ||
import OUDSTokensSemantic | ||
|
||
extension MockTheme { | ||
|
||
static let mockThemeOpacityRawToken: OpacityRawToken = 713 | ||
|
||
override var opacityTransparent: OpacitySemanticToken { Self.mockThemeOpacityRawToken } | ||
override var opacityWeaker: OpacitySemanticToken { Self.mockThemeOpacityRawToken } | ||
override var opacityWeak: OpacitySemanticToken { Self.mockThemeOpacityRawToken } | ||
override var opacityMedum: OpacitySemanticToken { Self.mockThemeOpacityRawToken } | ||
override var opacityEmphasis: OpacitySemanticToken { Self.mockThemeOpacityRawToken } | ||
override var opacityOpaque: OpacitySemanticToken { Self.mockThemeOpacityRawToken } | ||
} |
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
36 changes: 36 additions & 0 deletions
36
OUDS/Core/Tokens/RawTokens/Tests/OpacityRawTokensTests.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,36 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import XCTest | ||
import OUDSTokensRaw | ||
|
||
/// The aim of this tests class is to look for regressions in **opacity raw tokens**. | ||
/// Because these values will be at least generated through an external tool, is it not relevant to test each token values. | ||
/// Indeed, each future generation of Swift code may break theses tests because there are new values. | ||
/// However, in the semantics of border raw tokens, there will be some unchanged things like relationships between tokens. | ||
/// Thus this tests class just checks if such relationships are still here whatever the values at the end. | ||
final class OpacityRawTokensTests: XCTestCase { | ||
|
||
/// Whathever the values are, opacity raw tokens must keep their order relationships | ||
func testOrderRelationshipForWidths() throws { | ||
XCTAssertLessThan(OpacityRawTokens.opacity0, OpacityRawTokens.opacity100) | ||
XCTAssertLessThan(OpacityRawTokens.opacity100, OpacityRawTokens.opacity200) | ||
XCTAssertLessThan(OpacityRawTokens.opacity200, OpacityRawTokens.opacity300) | ||
XCTAssertLessThan(OpacityRawTokens.opacity300, OpacityRawTokens.opacity400) | ||
XCTAssertLessThan(OpacityRawTokens.opacity400, OpacityRawTokens.opacity500) | ||
XCTAssertLessThan(OpacityRawTokens.opacity500, OpacityRawTokens.opacity600) | ||
XCTAssertLessThan(OpacityRawTokens.opacity600, OpacityRawTokens.opacity700) | ||
XCTAssertLessThan(OpacityRawTokens.opacity700, OpacityRawTokens.opacity800) | ||
XCTAssertLessThan(OpacityRawTokens.opacity800, OpacityRawTokens.opacity900) | ||
} | ||
} |