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

Unified Diff: base/mac_util_unittest.mm

Issue 333008: Mac: Implement about:memory. (Closed)
Patch Set: Merged ToT. Created 11 years, 1 month 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 | « base/mac_util.mm ('k') | base/process_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac_util_unittest.mm
diff --git a/base/mac_util_unittest.mm b/base/mac_util_unittest.mm
index 162a74639864bc3f68d8b56c415f30b813641e18..0abdee7abd4061e5211085798bbe1c81a690f173 100644
--- a/base/mac_util_unittest.mm
+++ b/base/mac_util_unittest.mm
@@ -57,3 +57,47 @@ TEST_F(MacUtilTest, TestGrabWindowSnapshot) {
[color getRed:&red green:&green blue:&blue alpha:&alpha];
EXPECT_GE(red + green + blue, 3.0);
}
+
+TEST_F(MacUtilTest, TestGetAppBundlePath) {
+ FilePath out;
+
+ // Make sure it doesn't crash.
+ out = mac_util::GetAppBundlePath(FilePath());
+ EXPECT_TRUE(out.empty());
+
+ // Some more invalid inputs.
+ const char* invalid_inputs[] = {
+ "/", "/foo", "foo", "/foo/bar.", "foo/bar.", "/foo/bar./bazquux",
+ "foo/bar./bazquux", "foo/.app", "//foo",
+ };
+ for (size_t i = 0; i < arraysize(invalid_inputs); i++) {
+ out = mac_util::GetAppBundlePath(FilePath(invalid_inputs[i]));
+ EXPECT_TRUE(out.empty()) << "loop: " << i;
+ }
+
+ // Some valid inputs; this and |expected_outputs| should be in sync.
+ struct {
+ const char *in;
+ const char *expected_out;
+ } valid_inputs[] = {
+ { "FooBar.app/", "FooBar.app" },
+ { "/FooBar.app", "/FooBar.app" },
+ { "/FooBar.app/", "/FooBar.app" },
+ { "//FooBar.app", "//FooBar.app" },
+ { "/Foo/Bar.app", "/Foo/Bar.app" },
+ { "/Foo/Bar.app/", "/Foo/Bar.app" },
+ { "/F/B.app", "/F/B.app" },
+ { "/F/B.app/", "/F/B.app" },
+ { "/Foo/Bar.app/baz", "/Foo/Bar.app" },
+ { "/Foo/Bar.app/baz/", "/Foo/Bar.app" },
+ { "/Foo/Bar.app/baz/quux.app/quuux", "/Foo/Bar.app" },
+ { "/Applications/Google Foo.app/bar/Foo Helper.app/quux/Foo Helper",
+ "/Applications/Google Foo.app" },
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid_inputs); i++) {
+ out = mac_util::GetAppBundlePath(FilePath(valid_inputs[i].in));
+ EXPECT_FALSE(out.empty()) << "loop: " << i;
+ EXPECT_STREQ(valid_inputs[i].expected_out,
+ out.value().c_str()) << "loop: " << i;
+ }
+}
« no previous file with comments | « base/mac_util.mm ('k') | base/process_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698