From bf35d95e74ad85603005d2dcbded07c22b070012 Mon Sep 17 00:00:00 2001 From: arnonchen <745735906@qq.com> Date: Tue, 12 Nov 2024 14:38:15 +0800 Subject: [PATCH] fix(ios): fix HippyFontLoaderTest using local file --- hippy.podspec | 1 + tests/ios/HippyFontLoaderTest.m | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hippy.podspec b/hippy.podspec index ef43c7e17ff..7ef1bc1b2e8 100644 --- a/hippy.podspec +++ b/hippy.podspec @@ -365,6 +365,7 @@ Pod::Spec.new do |s| s.test_spec 'UnitTests' do |test_spec| test_spec.source_files = 'tests/ios/**/*.{h,m,mm}' + test_spec.resources = 'framework/examples/ios-demo/fonts/TTTGB-Medium.otf' test_spec.dependency 'OCMock' end diff --git a/tests/ios/HippyFontLoaderTest.m b/tests/ios/HippyFontLoaderTest.m index 6662c7473b8..51c23285fb7 100644 --- a/tests/ios/HippyFontLoaderTest.m +++ b/tests/ios/HippyFontLoaderTest.m @@ -44,8 +44,10 @@ - (void)tearDown { - (void)testHippyFontLoaderModule { NSString* invalidURL = @"https://example.url"; // set arbitrary valid font file url - NSString* validURL = @"https://zf.sc.chinaz.com/Files/DownLoad/upload/2024/1009/hanyihuaxianzijianti.ttf"; - NSString* fontFamily = @"HYHuaXianZi J"; + NSBundle *testBundle = [NSBundle bundleForClass:[self class]]; + NSString* filePath = [testBundle pathForResource:@"TTTGB-Medium" ofType:@"otf"]; + NSString* validURL = [@"file://" stringByAppendingString:filePath]; + NSString* fontFamily = @"TTTGB Medium"; HippyBridge *bridge = [[HippyBridge alloc] initWithDelegate:nil moduleProvider:nil launchOptions:nil executorKey:nil]; HippyFontLoaderModule *fontLoader = [[HippyFontLoaderModule alloc] init]; [fontLoader setValue:bridge forKey:@"bridge"]; @@ -109,11 +111,4 @@ - (void)testHippyFontLoaderModule { [[NSFileManager defaultManager] removeItemAtPath:[fontPath stringByDeletingLastPathComponent] error:nil]; } -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; -} - @end