mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-08-16 16:20:51 +03:00
Add unit test and example
This commit is contained in:
parent
f28d3caa3b
commit
60c761a9ce
@ -0,0 +1 @@
|
||||
API_PATH = https://dev.google.com
|
@ -0,0 +1 @@
|
||||
API_PATH = https://release.google.com
|
@ -0,0 +1,22 @@
|
||||
//
|
||||
// ContentBlockerRequestHandler.swift
|
||||
// ContentBlocker
|
||||
//
|
||||
// Created by Thanh Vu on 31/10/2023.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MobileCoreServices
|
||||
|
||||
class ContentBlockerRequestHandler: NSObject, NSExtensionRequestHandling {
|
||||
|
||||
func beginRequest(with context: NSExtensionContext) {
|
||||
let attachment = NSItemProvider(contentsOf: Bundle.main.url(forResource: "blockerList", withExtension: "json"))!
|
||||
|
||||
let item = NSExtensionItem()
|
||||
item.attachments = [attachment]
|
||||
|
||||
context.completeRequest(returningItems: [item], completionHandler: nil)
|
||||
}
|
||||
|
||||
}
|
13
Tests/Fixtures/TestProject/ContentBlocker/Info.plist
Normal file
13
Tests/Fixtures/TestProject/ContentBlocker/Info.plist
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.Safari.content-blocker</string>
|
||||
<key>NSExtensionPrincipalClass</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).ContentBlockerRequestHandler</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
10
Tests/Fixtures/TestProject/ContentBlocker/blockerList.json
Normal file
10
Tests/Fixtures/TestProject/ContentBlocker/blockerList.json
Normal file
@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"action": {
|
||||
"type": "block"
|
||||
},
|
||||
"trigger": {
|
||||
"url-filter": "webkit.svg"
|
||||
}
|
||||
}
|
||||
]
|
@ -16,6 +16,11 @@ options:
|
||||
buildPhase: none
|
||||
abcd:
|
||||
buildPhase: none
|
||||
globalTemplateAttributes:
|
||||
version: legacy
|
||||
configs:
|
||||
Debug: debug
|
||||
Release: release
|
||||
fileGroups:
|
||||
- Configs
|
||||
- FileGroup
|
||||
@ -79,7 +84,9 @@ targets:
|
||||
legacy:
|
||||
toolPath: /usr/bin/true
|
||||
passSettings: true
|
||||
|
||||
ContentBlocker:
|
||||
templates:
|
||||
- ContentBlockerTemplate
|
||||
App_macOS:
|
||||
type: application
|
||||
platform: macOS
|
||||
@ -497,6 +504,16 @@ schemes:
|
||||
targetTemplates:
|
||||
MyTemplate:
|
||||
scheme: {}
|
||||
ContentBlockerTemplate:
|
||||
platform: iOS
|
||||
type: app-extension
|
||||
settings:
|
||||
CODE_SIGN_IDENTITY: Apple Development
|
||||
configFiles:
|
||||
Debug: ContentBlocker/Configs/${version}/Debug.xcconfig
|
||||
Release: ContentBlocker/Configs/${version}/Release.xcconfig
|
||||
sources:
|
||||
- ContentBlocker
|
||||
aggregateTargets:
|
||||
SuperTarget:
|
||||
attributes:
|
||||
|
28
Tests/Fixtures/global_template_attributes_test.yml
Normal file
28
Tests/Fixtures/global_template_attributes_test.yml
Normal file
@ -0,0 +1,28 @@
|
||||
targetTemplates:
|
||||
ContentBlockerTemplate:
|
||||
platform: iOS
|
||||
type: app-extension
|
||||
settings:
|
||||
CODE_SIGN_IDENTITY: Apple Development
|
||||
configFiles:
|
||||
Debug: ContentBlocker/Configs/${version}/Debug.xcconfig
|
||||
Release: ContentBlocker/Configs/${version}/Release.xcconfig
|
||||
sources:
|
||||
- ContentBlocker
|
||||
|
||||
globalTemplateAttributes:
|
||||
version: legacy
|
||||
|
||||
name: Demo
|
||||
options:
|
||||
createIntermediateGroups: True
|
||||
targets:
|
||||
Demo:
|
||||
type: application
|
||||
platform: iOS
|
||||
deploymentTarget: "10.0"
|
||||
sources:
|
||||
- DemoXcodeGenGlobalTemplateAttribute
|
||||
ContentBlocker:
|
||||
templates:
|
||||
- ContentBlockerTemplate
|
@ -285,6 +285,15 @@ class SpecLoadingTests: XCTestCase {
|
||||
]
|
||||
try expect(project.targets.last?.sources) == ["SomeTarget", "doesWin", "templateVariable"]
|
||||
}
|
||||
|
||||
$0.it("lookup global template attributes") {
|
||||
let path = fixturePath + "global_template_attributes_test.yml"
|
||||
|
||||
let project = try loadSpec(path: path)
|
||||
let extensionTarget = project.targets.first!
|
||||
try expect(extensionTarget.configFiles["Debug"]) == "ContentBlocker/Configs/legacy/Debug.xcconfig"
|
||||
try expect(extensionTarget.configFiles["Release"]) == "ContentBlocker/Configs/legacy/Release.xcconfig"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user