Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: webrtc/test/testsupport/iosfileutils.mm

Issue 1178843002: Adds support for webrtc::test::ResourcePath on iOS (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Enabled more unit tests Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/test/testsupport/iosfileutils.mm
diff --git a/webrtc/test/testsupport/iosfileutils.mm b/webrtc/test/testsupport/iosfileutils.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d91456e5ee990fda70a8d94d74c7cae65e9ef161
--- /dev/null
+++ b/webrtc/test/testsupport/iosfileutils.mm
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2014 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#import <Foundation/Foundation.h>
+#include <string.h>
+
+#include "webrtc/base/checks.h"
+#include "webrtc/typedefs.h"
+
+std::string IOSResourcePath(std::string name, std::string extension) {
+ // Extract name of file and exclude any added path.
+ // Example: name: "audio_coding/testfile32kHz" => file_name: "testfile32kHz".
+ std::size_t pos = name.find_last_of("/");
+ DCHECK_NE(pos, std::string::npos);
+ std::string file_name = name.substr(pos + 1);
+ // Convert from UTF8 to NSString objects.
+ NSString* nameString =
henrika_webrtc 2015/06/11 10:50:31 Could you please comment on the memory handling de
henrika_webrtc 2015/06/11 12:27:56 Perhaps I should do: [[[NSString alloc] initWithU
henrika_webrtc 2015/06/11 13:10:59 sorry, or perhaps use the factory method stringWit
tkchin_webrtc 2015/06/12 01:30:26 You should enable ARC in GYP file. Use:
henrika_webrtc 2015/06/12 12:52:11 Thanks. Done changes but might have missed some de
tkchin_webrtc 2015/06/12 17:43:35 In this case it doesn't matter. StdStringFromNSStr
henrika_webrtc 2015/06/15 08:46:29 Thanks. Have shifted to using your methods.
+ [[NSString alloc] initWithUTF8String:file_name.c_str()];
+ NSString* typeString =
+ [[NSString alloc] initWithUTF8String:extension.c_str()];
+ // Get full pathname for the resource identified by the name and extension.
+ NSString* pathString = [[NSBundle mainBundle] pathForResource: nameString
+ ofType: typeString];
+ // Return a null-terminated UTF8 representation of |pathString|.
+ return pathString.UTF8String;
+}
« webrtc/test/testsupport/fileutils.cc ('K') | « webrtc/test/testsupport/fileutils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698