diff options
| author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-27 00:37:42 +0000 |
|---|---|---|
| committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-27 00:37:42 +0000 |
| commit | 647c2f0208e18b4cd747019d1ee61e12248a096f (patch) | |
| tree | 6de3e4ccb8240946f380de44de550c100c3aead8 /chrome/browser/cocoa/cocoa_test_helper.h | |
| parent | 4670de0e4ab9e02165d2b0d0c24ff9825e5bbff9 (diff) | |
| download | chromium_src-647c2f0208e18b4cd747019d1ee61e12248a096f.zip chromium_src-647c2f0208e18b4cd747019d1ee61e12248a096f.tar.gz chromium_src-647c2f0208e18b4cd747019d1ee61e12248a096f.tar.bz2 | |
[Mac] Make CocoaTest::TearDown() more scalable in the face of valgrind.
Changes from std::vector<> to std::set<> because set_difference()
works on sorted inputs.
The loop is broken into two parts. The outer loop continues
while progress is being made. The inner loop spins the event
loop while:
- no progress has been made; and
- it hasn't spun enough times; or
- it hasn't spun for long enough
The odd timeout calculation is because some sequences need the
event loop spun after a timeout, not until a timeout (difference
between taking the time at the start and at the end).
As long as I was changing comments, I (hopefully) removed the
royal "We" in appeasement of The Mentovai.
BUG=36677
TEST=tests continue to work, even under valgrind
Review URL: http://codereview.chromium.org/660213
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40185 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/cocoa_test_helper.h')
| -rw-r--r-- | chrome/browser/cocoa/cocoa_test_helper.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/cocoa_test_helper.h b/chrome/browser/cocoa/cocoa_test_helper.h index 5f51c54..7ef1775 100644 --- a/chrome/browser/cocoa/cocoa_test_helper.h +++ b/chrome/browser/cocoa/cocoa_test_helper.h @@ -81,16 +81,22 @@ class CocoaTest : public PlatformTest { CocoaTestHelperWindow* test_window(); private: - // Return a vector of currently open windows. Note that it is a vector - // instead of an NSArray because we don't want any retains placed on the - // windows in it and that the windows in this list may no longer be valid - // NSWindows any time after this returns. You can only use the pointer values - // in the vector for comparison purposes. - static std::vector<NSWindow*> ApplicationWindows(); + // Return a set of currently open windows. Avoiding NSArray so + // contents aren't retained, the pointer values can only be used for + // comparison purposes. Using std::set to make progress-checking + // convenient. + static std::set<NSWindow*> ApplicationWindows(); + + // Return a set of windows which are in |ApplicationWindows()| but + // not |initial_windows_|. + std::set<NSWindow*> WindowsLeft(); bool called_tear_down_; base::ScopedNSAutoreleasePool pool_; - std::vector<NSWindow*> initial_windows_; + + // Windows which existed at the beginning of the test. + std::set<NSWindow*> initial_windows_; + // Strong. Lazily created. This isn't wrapped in a scoped_nsobject because // we want to call [close] to destroy it rather than calling [release]. We // want to verify that [close] is actually removing our window and that it's |
