diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 23:37:40 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 23:37:40 +0000 |
commit | f164cea41472f9e9ec21579233e2c42a7b9d5184 (patch) | |
tree | 523c6aa180be86ace3ac7797e4c9c75c369dff57 /base/mac_util_unittest.mm | |
parent | 422c0f17466cddf30fd6815f9d3519a3815264c6 (diff) | |
download | chromium_src-f164cea41472f9e9ec21579233e2c42a7b9d5184.zip chromium_src-f164cea41472f9e9ec21579233e2c42a7b9d5184.tar.gz chromium_src-f164cea41472f9e9ec21579233e2c42a7b9d5184.tar.bz2 |
Mac: Implement about:memory.
This implements about:memory on Mac. It calls /bin/ps to obtain information
about processes (this is Apple's officially supported "API"). Unfortunately, ps
provides fairly minimal information (rss and vsize); top is better, but not a
stable API -- it has changed greatly between Mac OS 10.5 and 10.6, and moreover
the 10.6 version is more limited in its output formatting.
BUG=9653
TEST=Go to about:memory under a variety of conditions (with a variety of browsers loaded).
Review URL: http://codereview.chromium.org/333008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac_util_unittest.mm')
-rw-r--r-- | base/mac_util_unittest.mm | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/base/mac_util_unittest.mm b/base/mac_util_unittest.mm index 162a746..0abdee7 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; + } +} |