Skip to content

Commit

Permalink
[fluent2-tokens] Merging main -> fluent2-tokens (#1515)
Browse files Browse the repository at this point in the history
* Skip failing date picker tests (#1495)

* Fix BadgeField space bug (#1497)

* attempt to fix space bug

* add comment

* [XCUITests] Activity Indicator tests (#1493)

* initial activity indicator tests

* add transition to dark mode

* whitespace change

* add dark mode color assert

* add default color to identifier

* update comment

* add dark mode + update to use .*

* add #if DEBUG

* add #if DEBUG to SceneDelegate

* add constants

* add type

* change to hex code

* removing color tests

* Revert "removing color tests"

This reverts commit 79c20c0.

* removing color tests again

* remove SceneDelegate change

* small change

* make code more readable + have SwiftUI inherit from UIKit

* remove super

* [XCUITests] Indeterminate Progress Bar tests (#1503)

* add indeterminate progress bar tests

* update SwiftUI to inherit from UIKit

* remove super

* resolve comments

* [XCUITests] Table View Cell tests (#1508)

* add table view cell tests

* move single line asserts to function

* add comment

* Revert "[XCUITests] Table View Cell tests (#1508)" (#1511)

This reverts commit 1339ed0.

* Bumping FluentUI version (0.11.0) #1512

Co-authored-by: Lamine Male <106181067+laminesm@users.noreply.github.com>
Co-authored-by: Sophia Lee <sophia.lee0416@gmail.com>
  • Loading branch information
3 people committed Jan 25, 2023
1 parent 4938af0 commit c9cd9b2
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 23 deletions.
2 changes: 1 addition & 1 deletion MicrosoftFluentUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MicrosoftFluentUI'
s.version = '0.8.0'
s.version = '0.11.0'
s.summary = 'Fluent UI is a set of reusable UI controls and tools'
s.homepage = "https://www.microsoft.com/design/fluent/#/"
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
BlueprintName = "FluentUITests"
ReferencedContainer = "container:../FluentUI.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "DatePickerControllerTests/testSelectionManagerEnd()">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
skipped = "NO">
Expand Down
4 changes: 2 additions & 2 deletions ios/FluentUI.Demo/FluentUI.Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.8.0</string>
<string>1.11.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -26,7 +26,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>130</string>
<string>137.11.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
Expand Down
30 changes: 30 additions & 0 deletions ios/FluentUI.Demo/FluentUIDemoTests/ActivityIndicatorTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,38 @@ import XCTest
class ActivityIndicatorTest: BaseTest {
override var controlName: String { "ActivityIndicator" }

let inProgress: NSPredicate = NSPredicate(format: "identifier CONTAINS %@", "Activity Indicator that is in progress")
let progressHalted: NSPredicate = NSPredicate(format: "identifier CONTAINS %@", "Activity Indicator that is progress halted")

func activityIndicatorExists(status: NSPredicate) -> Bool {
return app.images.element(matching: status).exists
}

// launch test that ensures the demo app does not crash and is on the correct control page
func testLaunch() throws {
XCTAssertTrue(app.navigationBars[controlName].exists)
}

// tests start/stop functionality as well as hiding (activity indicator should disappear when stopped)
func testStartStopHide() throws {
let startStopButton: XCUIElement = app.buttons["Start / Stop activity"]
let hidesWhenStoppedButton: XCUIElement = app.cells.containing(.staticText, identifier: "Hides when stopped").firstMatch

XCTAssert(activityIndicatorExists(status: inProgress))
startStopButton.tap()
XCTAssert(!activityIndicatorExists(status: inProgress))

hidesWhenStoppedButton.tap()
XCTAssert(activityIndicatorExists(status: progressHalted))

startStopButton.tap()
XCTAssert(activityIndicatorExists(status: inProgress))
}

func testSizes() throws {
// ensures all 5 activity indicators sizes are shown
for i in 0...4 {
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size \(i).*")).element.exists)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,67 @@

import XCTest

class ActivityIndicatorTestSwiftUI: BaseTest {
override var controlName: String { "ActivityIndicator" }

class ActivityIndicatorTestSwiftUI: ActivityIndicatorTest {
override func setUpWithError() throws {
try super.setUpWithError()
app.staticTexts["SwiftUI Demo"].tap()
}

// launch test that ensures the demo app does not crash and is on the correct control page
func testLaunch() throws {
override func testLaunch() throws {
XCTAssertTrue(app.navigationBars.element(matching: NSPredicate(format: "identifier CONTAINS %@", controlName)).exists)
}

override func testStartStopHide() throws {
let animatingSwitch: XCUIElement = app.switches["Animating"]
let hidesWhenStoppedSwitch: XCUIElement = app.switches["Hides when stopped"]

hidesWhenStoppedSwitch.tap()
XCTAssert(activityIndicatorExists(status: inProgress))

animatingSwitch.tap()
XCTAssert(activityIndicatorExists(status: progressHalted))

hidesWhenStoppedSwitch.tap()
XCTAssert(!activityIndicatorExists(status: inProgress))

animatingSwitch.tap()
XCTAssert(activityIndicatorExists(status: inProgress))
}

override func testSizes() throws {
let animatingSwitch: XCUIElement = app.switches["Animating"]
let hidesWhenStoppedSwitch: XCUIElement = app.switches["Hides when stopped"]

XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 4")).element.exists)
app.buttons[".xLarge"].tap()
app.buttons[".large"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 3")).element.exists)
app.buttons[".large"].tap()
app.buttons[".medium"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 2")).element.exists)
app.buttons[".medium"].tap()
app.buttons[".small"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 1")).element.exists)
app.buttons[".small"].tap()
app.buttons[".xSmall"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 0")).element.exists)

hidesWhenStoppedSwitch.tap()
animatingSwitch.tap()

XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 0")).element.exists)
app.buttons[".xSmall"].tap()
app.buttons[".small"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 1")).element.exists)
app.buttons[".small"].tap()
app.buttons[".medium"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 2")).element.exists)
app.buttons[".medium"].tap()
app.buttons[".large"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 3")).element.exists)
app.buttons[".large"].tap()
app.buttons[".xLarge"].tap()
XCTAssert(app.images.containing(NSPredicate(format: "identifier MATCHES %@", "Activity Indicator.*size 4")).element.exists)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,35 @@ import XCTest
class IndeterminateProgressBarTest: BaseTest {
override var controlName: String { "IndeterminateProgressBar" }

let inProgress: NSPredicate = NSPredicate(format: "identifier CONTAINS %@", "Indeterminate Progress Bar that is in progress")
let progressHalted: NSPredicate = NSPredicate(format: "identifier CONTAINS %@", "Indeterminate Progress Bar that is progress halted")

func indeterminateProgressBarExists(status: NSPredicate) -> Bool {
return app.otherElements.element(matching: status).exists
}

// launch test that ensures the demo app does not crash and is on the correct control page
func testLaunch() throws {
XCTAssertTrue(app.navigationBars[controlName].exists)
}

// tests start/stop functionality as well as hiding (indeterminate progress bar should disappear when stopped)
func testStartStopHide() throws {
let startStopButton: XCUIElement = app.buttons["Start / Stop activity"]
let hidesWhenStoppedButton: XCUIElement = app.cells.containing(.staticText, identifier: "Hides when stopped").firstMatch

XCTAssert(indeterminateProgressBarExists(status: inProgress))
XCTAssert(!indeterminateProgressBarExists(status: progressHalted))
startStopButton.tap()
XCTAssert(!indeterminateProgressBarExists(status: inProgress))
XCTAssert(!indeterminateProgressBarExists(status: progressHalted))

hidesWhenStoppedButton.tap()
XCTAssert(!indeterminateProgressBarExists(status: inProgress))
XCTAssert(indeterminateProgressBarExists(status: progressHalted))

startStopButton.tap()
XCTAssert(indeterminateProgressBarExists(status: inProgress))
XCTAssert(!indeterminateProgressBarExists(status: progressHalted))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,35 @@

import XCTest

class IndeterminateProgressBarTestSwiftUI: BaseTest {
override var controlName: String { "IndeterminateProgressBar" }

class IndeterminateProgressBarTestSwiftUI: IndeterminateProgressBarTest {
override func setUpWithError() throws {
try super.setUpWithError()
app.staticTexts["SwiftUI Demo"].tap()
}

// launch test that ensures the demo app does not crash and is on the correct control page
func testLaunch() throws {
override func testLaunch() throws {
XCTAssertTrue(app.navigationBars.element(matching: NSPredicate(format: "identifier CONTAINS %@", controlName)).exists)
}

override func testStartStopHide() throws {
let animatingSwitch: XCUIElement = app.switches["Animating"]
let hidesWhenStoppedSwitch: XCUIElement = app.switches["Hides when stopped"]

hidesWhenStoppedSwitch.tap()
XCTAssert(indeterminateProgressBarExists(status: inProgress))
XCTAssert(!indeterminateProgressBarExists(status: progressHalted))

animatingSwitch.tap()
XCTAssert(!indeterminateProgressBarExists(status: inProgress))
XCTAssert(indeterminateProgressBarExists(status: progressHalted))

hidesWhenStoppedSwitch.tap()
XCTAssert(!indeterminateProgressBarExists(status: inProgress))
XCTAssert(!indeterminateProgressBarExists(status: progressHalted))

animatingSwitch.tap()
XCTAssert(indeterminateProgressBarExists(status: inProgress))
XCTAssert(!indeterminateProgressBarExists(status: progressHalted))
}
}
4 changes: 2 additions & 2 deletions ios/FluentUI.Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.8.0</string>
<string>0.11.0</string>
<key>CFBundleVersion</key>
<string>0.8.0</string>
<string>0.11.0</string>
</dict>
</plist>
26 changes: 23 additions & 3 deletions ios/FluentUI/ActivityIndicator/ActivityIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,23 @@ public struct ActivityIndicator: View, TokenizedControlView {
"Accessibility.ActivityIndicator.Stopped.label".localized
}()

SemiRing(color: color,
thickness: tokenSet[.thickness].float,
accessibilityLabel: accessibilityLabel)
#if DEBUG
let accessibilityIdentifier: String = {
let status: String = state.isAnimating ? "in progress" : "progress halted"
return "Activity Indicator that is \(status) and size \(state.size.rawValue)"
}()

let semiRing = SemiRing(color: color,
thickness: tokenSet[.thickness].float,
accessibilityLabel: accessibilityLabel,
accessibilityIdentifier: accessibilityIdentifier)
#else
let semiRing = SemiRing(color: color,
thickness: tokenSet[.thickness].float,
accessibilityLabel: accessibilityLabel)
#endif

semiRing
.modifyIf(state.isAnimating, { animatedView in
animatedView
.rotationEffect(.degrees(rotationAngle), anchor: .center)
Expand Down Expand Up @@ -92,6 +106,9 @@ public struct ActivityIndicator: View, TokenizedControlView {
var color: Color
var thickness: CGFloat
var accessibilityLabel: String
#if DEBUG
var accessibilityIdentifier: String
#endif

public var body: some View {
Circle()
Expand All @@ -103,6 +120,9 @@ public struct ActivityIndicator: View, TokenizedControlView {
.accessibilityElement(children: .ignore)
.accessibility(addTraits: .isImage)
.accessibility(label: Text(accessibilityLabel))
#if DEBUG
.accessibility(identifier: accessibilityIdentifier)
#endif
}

private let semiRingStartFraction: CGFloat = 0.0
Expand Down
8 changes: 5 additions & 3 deletions ios/FluentUI/Badge Field/BadgeField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,9 @@ open class BadgeField: UIView {
}

private func updateLabelsVisibility(textFieldContent: String? = nil) {
let textFieldContent = textFieldContent ?? self.textFieldContent
var textFieldContent = textFieldContent ?? self.textFieldContent
// does not trim textFieldContent if it only contains whitespace
textFieldContent = textFieldContent.trimmingCharacters(in: .whitespaces) == "" ? textFieldContent : textFieldContent.trimmed()
labelView.isHidden = label.isEmpty
placeholderView.isHidden = !labelView.isHidden || !badges.isEmpty || !textFieldContent.isEmpty
setNeedsLayout()
Expand Down Expand Up @@ -1185,13 +1187,13 @@ extension BadgeField: UITextFieldDelegate {
let didBadge = badgeText(newString, force: false)
if !didBadge {
// Placeholder
updateLabelsVisibility(textFieldContent: newString.trimmed())
updateLabelsVisibility(textFieldContent: newString)
badgeFieldDelegate?.badgeField?(self, willChangeTextFieldContentWithText: newString.trimmed())
}
return !didBadge
}

updateLabelsVisibility(textFieldContent: newString.trimmed())
updateLabelsVisibility(textFieldContent: newString)

// Handle delete key
if string.isEmpty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public struct IndeterminateProgressBar: View, TokenizedControlView {
:
"Accessibility.ActivityIndicator.Stopped.label".localized
}()
#if DEBUG
let accessibilityIdentifier: String = "Indeterminate Progress Bar that is \(state.isAnimating ? "in progress" : "progress halted")"
#endif

Rectangle()
.fill(LinearGradient(gradient: Gradient(colors: [backgroundColor, gradientColor, backgroundColor]),
Expand All @@ -57,6 +60,9 @@ public struct IndeterminateProgressBar: View, TokenizedControlView {
alignment: .center)
.background(backgroundColor)
.accessibilityLabel(Text(accessibilityLabel))
#if DEBUG
.accessibilityIdentifier(accessibilityIdentifier)
#endif
.accessibilityAddTraits(.updatesFrequently)
.modifyIf(state.isAnimating, { view in
view
Expand Down
4 changes: 2 additions & 2 deletions macos/FluentUI/FluentUI-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.8.0</string>
<string>0.11.0</string>
<key>CFBundleVersion</key>
<string>0.8.0</string>
<string>0.11.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions macos/FluentUITestApp/FluentUITestApp-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.8.0</string>
<string>0.11.0</string>
<key>CFBundleVersion</key>
<string>55</string>
<string>62.11.0</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit c9cd9b2

Please sign in to comment.