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

Unified Diff: util/mac/launchd_test.mm

Issue 989733003: util/mac: Provide wrappers for <launch.h> functions deprecated in 10.10 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: DEPS Created 5 years, 9 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
« no previous file with comments | « util/mac/launchd.mm ('k') | util/mac/service_management.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mac/launchd_test.mm
diff --git a/util/mac/launchd_test.mm b/util/mac/launchd_test.mm
index 03953cdfc3b41e6ffde98306605c45e038a5c802..65722a42cbaab2968c8e6c712dc3965bea78d3e8 100644
--- a/util/mac/launchd_test.mm
+++ b/util/mac/launchd_test.mm
@@ -61,9 +61,8 @@ TEST(Launchd, CFPropertyToLaunchData_Integer) {
NSNumber* integer_ns = integer_nses[index];
launch_data.reset(CFPropertyToLaunchData(integer_ns));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_INTEGER, launch_data_get_type(launch_data));
- EXPECT_EQ(
- [integer_ns longLongValue], launch_data_get_integer(launch_data))
+ ASSERT_EQ(LAUNCH_DATA_INTEGER, LaunchDataGetType(launch_data));
+ EXPECT_EQ([integer_ns longLongValue], LaunchDataGetInteger(launch_data))
<< "index " << index;
}
}
@@ -91,9 +90,9 @@ TEST(Launchd, CFPropertyToLaunchData_FloatingPoint) {
NSNumber* double_ns = double_nses[index];
launch_data.reset(CFPropertyToLaunchData(double_ns));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_REAL, launch_data_get_type(launch_data));
+ ASSERT_EQ(LAUNCH_DATA_REAL, LaunchDataGetType(launch_data));
double expected_double_value = [double_ns doubleValue];
- double observed_double_value = launch_data_get_real(launch_data);
+ double observed_double_value = LaunchDataGetReal(launch_data);
bool expected_is_nan = std::isnan(expected_double_value);
EXPECT_EQ(expected_is_nan, std::isnan(observed_double_value));
if (!expected_is_nan) {
@@ -117,11 +116,11 @@ TEST(Launchd, CFPropertyToLaunchData_Boolean) {
NSNumber* bool_ns = bool_nses[index];
launch_data.reset(CFPropertyToLaunchData(bool_ns));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_BOOL, launch_data_get_type(launch_data));
+ ASSERT_EQ(LAUNCH_DATA_BOOL, LaunchDataGetType(launch_data));
if ([bool_ns boolValue]) {
- EXPECT_TRUE(launch_data_get_bool(launch_data));
+ EXPECT_TRUE(LaunchDataGetBool(launch_data));
} else {
- EXPECT_FALSE(launch_data_get_bool(launch_data));
+ EXPECT_FALSE(LaunchDataGetBool(launch_data));
}
}
}
@@ -141,8 +140,8 @@ TEST(Launchd, CFPropertyToLaunchData_String) {
NSString* string_ns = string_nses[index];
launch_data.reset(CFPropertyToLaunchData(string_ns));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_data));
- EXPECT_STREQ([string_ns UTF8String], launch_data_get_string(launch_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_data));
+ EXPECT_STREQ([string_ns UTF8String], LaunchDataGetString(launch_data));
}
}
}
@@ -156,10 +155,10 @@ TEST(Launchd, CFPropertyToLaunchData_Data) {
NSData* data_ns = [NSData dataWithBytes:data_c length:sizeof(data_c)];
launch_data.reset(CFPropertyToLaunchData(data_ns));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_OPAQUE, launch_data_get_type(launch_data));
- EXPECT_EQ(sizeof(data_c), launch_data_get_opaque_size(launch_data));
- EXPECT_EQ(
- 0, memcmp(launch_data_get_opaque(launch_data), data_c, sizeof(data_c)));
+ ASSERT_EQ(LAUNCH_DATA_OPAQUE, LaunchDataGetType(launch_data));
+ EXPECT_EQ(sizeof(data_c), LaunchDataGetOpaqueSize(launch_data));
+ EXPECT_EQ(0,
+ memcmp(LaunchDataGetOpaque(launch_data), data_c, sizeof(data_c)));
}
}
@@ -173,14 +172,13 @@ TEST(Launchd, CFPropertyToLaunchData_Dictionary) {
launch_data.reset(CFPropertyToLaunchData(dictionary_ns));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_DICTIONARY, launch_data_get_type(launch_data));
- EXPECT_EQ([dictionary_ns count], launch_data_dict_get_count(launch_data));
+ ASSERT_EQ(LAUNCH_DATA_DICTIONARY, LaunchDataGetType(launch_data));
+ EXPECT_EQ([dictionary_ns count], LaunchDataDictGetCount(launch_data));
- launch_data_t launch_lookup_data =
- launch_data_dict_lookup(launch_data, "key");
+ launch_data_t launch_lookup_data = LaunchDataDictLookup(launch_data, "key");
ASSERT_TRUE(launch_lookup_data);
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_lookup_data));
- EXPECT_STREQ("value", launch_data_get_string(launch_lookup_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_lookup_data));
+ EXPECT_STREQ("value", LaunchDataGetString(launch_lookup_data));
}
}
@@ -192,19 +190,18 @@ TEST(Launchd, CFPropertyToLaunchData_Array) {
launch_data.reset(CFPropertyToLaunchData(array_ns));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_ARRAY, launch_data_get_type(launch_data));
- EXPECT_EQ([array_ns count], launch_data_array_get_count(launch_data));
+ ASSERT_EQ(LAUNCH_DATA_ARRAY, LaunchDataGetType(launch_data));
+ EXPECT_EQ([array_ns count], LaunchDataArrayGetCount(launch_data));
- launch_data_t launch_lookup_data =
- launch_data_array_get_index(launch_data, 0);
+ launch_data_t launch_lookup_data = LaunchDataArrayGetIndex(launch_data, 0);
ASSERT_TRUE(launch_lookup_data);
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_lookup_data));
- EXPECT_STREQ("element_1", launch_data_get_string(launch_lookup_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_lookup_data));
+ EXPECT_STREQ("element_1", LaunchDataGetString(launch_lookup_data));
- launch_lookup_data = launch_data_array_get_index(launch_data, 1);
+ launch_lookup_data = LaunchDataArrayGetIndex(launch_data, 1);
ASSERT_TRUE(launch_lookup_data);
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_lookup_data));
- EXPECT_STREQ("element_2", launch_data_get_string(launch_lookup_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_lookup_data));
+ EXPECT_STREQ("element_2", LaunchDataGetString(launch_lookup_data));
}
}
@@ -248,55 +245,55 @@ TEST(Launchd, CFPropertyToLaunchData_RealWorldJobDictionary) {
launch_data.reset(CFPropertyToLaunchData(job_dictionary));
ASSERT_TRUE(launch_data.get());
- ASSERT_EQ(LAUNCH_DATA_DICTIONARY, launch_data_get_type(launch_data));
- EXPECT_EQ(4u, launch_data_dict_get_count(launch_data));
+ ASSERT_EQ(LAUNCH_DATA_DICTIONARY, LaunchDataGetType(launch_data));
+ EXPECT_EQ(4u, LaunchDataDictGetCount(launch_data));
launch_data_t launch_lookup_data =
- launch_data_dict_lookup(launch_data, LAUNCH_JOBKEY_LABEL);
+ LaunchDataDictLookup(launch_data, LAUNCH_JOBKEY_LABEL);
ASSERT_TRUE(launch_lookup_data);
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_lookup_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_lookup_data));
EXPECT_STREQ("com.example.job.rebooter",
- launch_data_get_string(launch_lookup_data));
+ LaunchDataGetString(launch_lookup_data));
launch_lookup_data =
- launch_data_dict_lookup(launch_data, LAUNCH_JOBKEY_ONDEMAND);
+ LaunchDataDictLookup(launch_data, LAUNCH_JOBKEY_ONDEMAND);
ASSERT_TRUE(launch_lookup_data);
- ASSERT_EQ(LAUNCH_DATA_BOOL, launch_data_get_type(launch_lookup_data));
- EXPECT_TRUE(launch_data_get_bool(launch_lookup_data));
+ ASSERT_EQ(LAUNCH_DATA_BOOL, LaunchDataGetType(launch_lookup_data));
+ EXPECT_TRUE(LaunchDataGetBool(launch_lookup_data));
launch_lookup_data =
- launch_data_dict_lookup(launch_data, LAUNCH_JOBKEY_PROGRAMARGUMENTS);
+ LaunchDataDictLookup(launch_data, LAUNCH_JOBKEY_PROGRAMARGUMENTS);
ASSERT_TRUE(launch_lookup_data);
- ASSERT_EQ(LAUNCH_DATA_ARRAY, launch_data_get_type(launch_lookup_data));
- EXPECT_EQ(3u, launch_data_array_get_count(launch_lookup_data));
+ ASSERT_EQ(LAUNCH_DATA_ARRAY, LaunchDataGetType(launch_lookup_data));
+ EXPECT_EQ(3u, LaunchDataArrayGetCount(launch_lookup_data));
launch_data_t launch_sublookup_data =
- launch_data_array_get_index(launch_lookup_data, 0);
+ LaunchDataArrayGetIndex(launch_lookup_data, 0);
ASSERT_TRUE(launch_sublookup_data);
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_sublookup_data));
- EXPECT_STREQ("/bin/bash", launch_data_get_string(launch_sublookup_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_sublookup_data));
+ EXPECT_STREQ("/bin/bash", LaunchDataGetString(launch_sublookup_data));
- launch_sublookup_data = launch_data_array_get_index(launch_lookup_data, 1);
+ launch_sublookup_data = LaunchDataArrayGetIndex(launch_lookup_data, 1);
ASSERT_TRUE(launch_sublookup_data);
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_sublookup_data));
- EXPECT_STREQ("-c", launch_data_get_string(launch_sublookup_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_sublookup_data));
+ EXPECT_STREQ("-c", LaunchDataGetString(launch_sublookup_data));
- launch_sublookup_data = launch_data_array_get_index(launch_lookup_data, 2);
+ launch_sublookup_data = LaunchDataArrayGetIndex(launch_lookup_data, 2);
ASSERT_TRUE(launch_sublookup_data);
- ASSERT_EQ(LAUNCH_DATA_STRING, launch_data_get_type(launch_sublookup_data));
- EXPECT_STREQ("/sbin/reboot", launch_data_get_string(launch_sublookup_data));
+ ASSERT_EQ(LAUNCH_DATA_STRING, LaunchDataGetType(launch_sublookup_data));
+ EXPECT_STREQ("/sbin/reboot", LaunchDataGetString(launch_sublookup_data));
launch_lookup_data =
- launch_data_dict_lookup(launch_data, LAUNCH_JOBKEY_MACHSERVICES);
+ LaunchDataDictLookup(launch_data, LAUNCH_JOBKEY_MACHSERVICES);
ASSERT_TRUE(launch_lookup_data);
- ASSERT_EQ(LAUNCH_DATA_DICTIONARY, launch_data_get_type(launch_lookup_data));
- EXPECT_EQ(1u, launch_data_dict_get_count(launch_lookup_data));
+ ASSERT_EQ(LAUNCH_DATA_DICTIONARY, LaunchDataGetType(launch_lookup_data));
+ EXPECT_EQ(1u, LaunchDataDictGetCount(launch_lookup_data));
- launch_sublookup_data = launch_data_dict_lookup(
+ launch_sublookup_data = LaunchDataDictLookup(
launch_lookup_data, "com.example.service.rebooter");
ASSERT_TRUE(launch_sublookup_data);
- ASSERT_EQ(LAUNCH_DATA_BOOL, launch_data_get_type(launch_sublookup_data));
- EXPECT_TRUE(launch_data_get_bool(launch_sublookup_data));
+ ASSERT_EQ(LAUNCH_DATA_BOOL, LaunchDataGetType(launch_sublookup_data));
+ EXPECT_TRUE(LaunchDataGetBool(launch_sublookup_data));
}
}
« no previous file with comments | « util/mac/launchd.mm ('k') | util/mac/service_management.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698