Skip to content

Commit

Permalink
Test case fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcprux committed Oct 17, 2024
1 parent 3c95660 commit 3054fd2
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 745 deletions.
4 changes: 0 additions & 4 deletions Darwin/Sources/AppDroidAppMain.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import SwiftUI
import AppDroid

Expand Down
674 changes: 0 additions & 674 deletions LICENSE.GPL

This file was deleted.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://source.skip.tools/skip.git", from: "1.1.10"),
.package(url: "https://source.skip.tools/skip-ui.git", branch: "main"),
.package(url: "https://source.skip.tools/skip-ui.git", from: "1.0.0"),
.package(url: "https://source.skip.tools/skip-bridge.git", branch: "main"),
.package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"),
],
Expand Down
4 changes: 0 additions & 4 deletions Sources/AppDroid/AppDroid.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

public class AppDroidModule {
}
4 changes: 0 additions & 4 deletions Sources/AppDroid/AppDroidApp.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import Foundation
import OSLog
import SwiftUI
Expand Down
4 changes: 0 additions & 4 deletions Sources/AppDroid/BridgeView.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import SwiftUI
import AppDroidModel

Expand Down
4 changes: 0 additions & 4 deletions Sources/AppDroid/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import SwiftUI

public struct ContentView: View {
Expand Down
5 changes: 0 additions & 5 deletions Sources/AppDroidModel/AppDroidKotlin.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

//import Foundation

// SKIP @bridgeToSwift
func getJavaSystemProperty(_ name: String) -> String? {
Expand Down
4 changes: 0 additions & 4 deletions Sources/AppDroidModel/Swift/AppDroidSwift.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import Foundation

// SKIP @bridgeToKotlin
Expand Down
35 changes: 16 additions & 19 deletions Tests/AppDroidModelTests/AppDroidModelTests.swift
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import XCTest
import OSLog
import Foundation
import SkipBridge
@testable import AppDroidModel

let logger: Logger = Logger(subsystem: "AppDroidModel", category: "Tests")

@available(macOS 13, *)
final class AppDroidModelTests: XCTestCase {
override func setUp() {
#if SKIP
loadPeerLibrary(packageName: "skipapp-appdroid", moduleName: "AppDroidModel")
#endif
}

func testAppDroidModel() throws {
logger.log("running testAppDroidModel")
XCTAssertEqual(1 + 2, 3, "basic test")

// load the TestData.json file from the Resources folder and decode it into a struct
let resourceURL: URL = try XCTUnwrap(Bundle.module.url(forResource: "TestData", withExtension: "json"))
let testData = try JSONDecoder().decode(TestData.self, from: Data(contentsOf: resourceURL))
XCTAssertEqual("AppDroidModel", testData.testModuleName)
#if SKIP
XCTAssertEqual("/", getJavaSystemProperty("file.separator"))
#else
throw XCTSkip("getJavaSystemProperty only works in transpiled test")
#endif
}
}

struct TestData : Codable, Hashable {
var testModuleName: String
}
func testClosure() {
XCTAssertEqual("value = 1", swiftClosure1Var(1))
}
}
22 changes: 9 additions & 13 deletions Tests/AppDroidModelTests/XCSkipTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import Foundation
//import Foundation
#if os(macOS) // Skip transpiled tests only run on macOS targets
import SkipTest

Expand All @@ -22,11 +18,11 @@ final class XCSkipTests: XCTestCase, XCGradleHarness {
}
#endif

/// True when running in a transpiled Java runtime environment
let isJava = ProcessInfo.processInfo.environment["java.io.tmpdir"] != nil
/// True when running within an Android environment (either an emulator or device)
let isAndroid = isJava && ProcessInfo.processInfo.environment["ANDROID_ROOT"] != nil
/// True is the transpiled code is currently running in the local Robolectric test environment
let isRobolectric = isJava && !isAndroid
/// True if the system's `Int` type is 32-bit.
let is32BitInteger = Int64(Int.max) == Int64(Int32.max)
///// True when running in a transpiled Java runtime environment
//let isJava = ProcessInfo.processInfo.environment["java.io.tmpdir"] != nil
///// True when running within an Android environment (either an emulator or device)
//let isAndroid = isJava && ProcessInfo.processInfo.environment["ANDROID_ROOT"] != nil
///// True is the transpiled code is currently running in the local Robolectric test environment
//let isRobolectric = isJava && !isAndroid
///// True if the system's `Int` type is 32-bit.
//let is32BitInteger = Int64(Int.max) == Int64(Int32.max)
6 changes: 1 addition & 5 deletions Tests/AppDroidTests/AppDroidTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import XCTest
import OSLog
import Foundation
Expand All @@ -24,4 +20,4 @@ final class AppDroidTests: XCTestCase {

struct TestData : Codable, Hashable {
var testModuleName: String
}
}
4 changes: 0 additions & 4 deletions Tests/AppDroidTests/XCSkipTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import Foundation
#if os(macOS) // Skip transpiled tests only run on macOS targets
import SkipTest
Expand Down

0 comments on commit 3054fd2

Please sign in to comment.