From e0b059da586f258c400975cc8891f96ad109e7b2 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 15 Sep 2023 14:16:50 +0530 Subject: [PATCH] Added iOS MPPFileInfo for tests --- mediapipe/tasks/ios/test/utils/BUILD | 10 +++++ .../ios/test/utils/sources/MPPFileInfo.h | 42 +++++++++++++++++++ .../ios/test/utils/sources/MPPFileInfo.m | 33 +++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 mediapipe/tasks/ios/test/utils/BUILD create mode 100644 mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.h create mode 100644 mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.m diff --git a/mediapipe/tasks/ios/test/utils/BUILD b/mediapipe/tasks/ios/test/utils/BUILD new file mode 100644 index 000000000..3d9e1b20f --- /dev/null +++ b/mediapipe/tasks/ios/test/utils/BUILD @@ -0,0 +1,10 @@ +package(default_visibility = ["//mediapipe/tasks:internal"]) + +licenses(["notice"]) + +objc_library( + name = "MPPFileInfo", + srcs = ["sources/MPPFileInfo.m"], + hdrs = ["sources/MPPFileInfo.h"], + module_name = "MPPFileInfo", +) diff --git a/mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.h b/mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.h new file mode 100644 index 000000000..666ed0ace --- /dev/null +++ b/mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.h @@ -0,0 +1,42 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MPPFileInfo : NSObject + +/** The name of the file. */ +@property(nonatomic, readonly) NSString *name; + +/** The type of the file. */ +@property(nonatomic, readonly) NSString *type; + +/** The path to file in the app bundle. */ +@property(nonatomic, readonly, nullable) NSString *path; + +/** + * Initializes an `MPPFileInfo` using the given name and type of file. + * + * @param name The name of the file. + * @param type The type of the file. + * + * @return The `MPPFileInfo` with the given name and type of file. + */ +- (instancetype)initWithName:(NSString *)name type:(NSString *)type; + +@end + +NS_ASSUME_NONNULL_END diff --git a/mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.m b/mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.m new file mode 100644 index 000000000..ef35f9bb8 --- /dev/null +++ b/mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.m @@ -0,0 +1,33 @@ +// Copyright 2023 The TensorFlow Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "mediapipe/tasks/ios/test/utils/sources/MPPFileInfo.h" + +@implementation MPPFileInfo + +- (instancetype)initWithName:(NSString *)name type:(NSString *)type { + self = [super init]; + if (self) { + _name = name; + _type = type; + } + + return self; +} + +- (NSString *)path { + return [[NSBundle bundleForClass:self.class] pathForResource:self.name ofType:self.type]; +} + +@end