Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//
// BackgroundStyleUITests.swift
// OpenSwiftUIUITests

import Testing
import SnapshotTesting

@MainActor
@Suite(.snapshots(record: .never, diffTool: diffTool))
struct BackgroundStyleUITests {
@Test
func backgroundDefault() {
struct ContentView: View {
var body: some View {
Rectangle()
.fill(.background)
.frame(width: 100, height: 100)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test(.disabled {
#if os(macOS)
// FIXME: Update RenderShape DL
true
#else
false
#endif
})
func backgroundInGroup() {
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.fill(.background)
.frame(width: 100, height: 50)
Rectangle()
.fill(.background)
.frame(width: 100, height: 50)
._addingBackgroundGroup()
}
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func backgroundInLayer() {
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.fill(.background)
.frame(width: 100, height: 50)
Rectangle()
.fill(.background)
.frame(width: 100, height: 50)
._addingBackgroundLayer()
}
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func backgroundCustomStyle() {
struct ContentView: View {
var body: some View {
Rectangle()
.fill(.background)
.frame(width: 100, height: 100)
.backgroundStyle(.blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func backgroundNestedCustomStyle() {
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.fill(.background)
.frame(width: 100, height: 50)
Rectangle()
.fill(.background)
.frame(width: 100, height: 50)
.backgroundStyle(.red)
}
.backgroundStyle(.blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func backgroundWithContent() {
struct ContentView: View {
var body: some View {
ZStack {
Rectangle()
.fill(.background)
Capsule()
.foregroundStyle(.primary)
}
.frame(width: 100, height: 100)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
//
// ForegroundStyleUITests.swift
// OpenSwiftUIUITests

import Testing
import SnapshotTesting

@MainActor
@Suite(.snapshots(record: .never, diffTool: diffTool))
struct ForegroundStyleUITests {
@Test
func foregroundDefault() {
struct ContentView: View {
var body: some View {
Rectangle()
.fill(.foreground)
.frame(width: 100, height: 100)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func foregroundSingleStyle() {
struct ContentView: View {
var body: some View {
Rectangle()
.frame(width: 100, height: 100)
.foregroundStyle(.blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func foregroundPairStyle() {
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.fill(.primary)
.frame(width: 100, height: 50)
Rectangle()
.fill(.secondary)
.frame(width: 100, height: 50)
}
.foregroundStyle(.red, .blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func foregroundTripleStyle() {
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.fill(.primary)
.frame(width: 100, height: 34)
Rectangle()
.fill(.secondary)
.frame(width: 100, height: 33)
Rectangle()
.fill(.tertiary)
.frame(width: 100, height: 33)
}
.foregroundStyle(.red, .green, .blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func foregroundNestedStyle() {
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.frame(width: 100, height: 50)
Rectangle()
.frame(width: 100, height: 50)
.foregroundStyle(.red)
}
.foregroundStyle(.blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test(.disabled("Text is not supported yet"))
func foregroundWithText() {
struct ContentView: View {
var body: some View {
Text("Hello")
.font(.largeTitle)
.foregroundStyle(.blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}

@Test
func foregroundHierarchical() {
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.fill(.primary)
.frame(width: 100, height: 50)
Rectangle()
.fill(.secondary)
.frame(width: 100, height: 50)
}
.foregroundStyle(.blue)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
}
}
Loading
Loading