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

Side by Side Diff: chrome/browser/cocoa/cocoa_test_helper.h

Issue 333017: Fixes up bookmark bubbles and the browser window so that they shut down corre... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ 5 #ifndef CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_
6 #define CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ 6 #define CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // need to close it at a very specific time; just before we enter our clean 98 // need to close it at a very specific time; just before we enter our clean
99 // up loop in TearDown. 99 // up loop in TearDown.
100 CocoaTestHelperWindow* test_window_; 100 CocoaTestHelperWindow* test_window_;
101 }; 101 };
102 102
103 // A macro defining a standard set of tests to run on a view. Since we can't 103 // A macro defining a standard set of tests to run on a view. Since we can't
104 // inherit tests, this macro saves us a lot of duplicate code. Handles simply 104 // inherit tests, this macro saves us a lot of duplicate code. Handles simply
105 // displaying the view to make sure it won't crash, as well as removing it 105 // displaying the view to make sure it won't crash, as well as removing it
106 // from a window. All tests that work with NSView subclasses and/or 106 // from a window. All tests that work with NSView subclasses and/or
107 // NSViewController subclasses should use it. 107 // NSViewController subclasses should use it.
108 #define TEST_VIEW(test_fixture, view_member_name) \ 108 #define TEST_VIEW(test_fixture, test_view) \
109 TEST_F(test_fixture, AddRemove##test_fixture) { \ 109 TEST_F(test_fixture, AddRemove##test_fixture) { \
110 scoped_nsobject<NSView> view([view_member_name retain]); \ 110 scoped_nsobject<NSView> view([test_view retain]); \
111 EXPECT_EQ([test_window() contentView], [view_member_name superview]); \ 111 EXPECT_EQ([test_window() contentView], [view superview]); \
112 [view_member_name removeFromSuperview]; \ 112 [view removeFromSuperview]; \
113 EXPECT_FALSE([view_member_name superview]); \ 113 EXPECT_FALSE([view superview]); \
114 } \ 114 } \
115 TEST_F(test_fixture, Display##test_fixture) { \ 115 TEST_F(test_fixture, Display##test_fixture) { \
116 [view_member_name display]; \ 116 [test_view display]; \
117 } 117 }
118 118
119 // The classes below are deprecated and will be removed shortly. Do not write 119 // The classes below are deprecated and will be removed shortly. Do not write
120 // any tests based on them. 120 // any tests based on them.
121 121
122 // A class that initializes Cocoa and sets up resources for many of our 122 // A class that initializes Cocoa and sets up resources for many of our
123 // Cocoa controller unit tests. It does several key things: 123 // Cocoa controller unit tests. It does several key things:
124 // - Creates and displays an empty Cocoa window for views to live in 124 // - Creates and displays an empty Cocoa window for views to live in
125 // - Loads the appropriate bundle so nib loading works. When loading the 125 // - Loads the appropriate bundle so nib loading works. When loading the
126 // nib in the class being tested, your must use |mac_util::MainAppBundle()| 126 // nib in the class being tested, your must use |mac_util::MainAppBundle()|
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void clearFirstResponder() { 182 void clearFirstResponder() {
183 [window_ setPretendIsKeyWindow:NO]; 183 [window_ setPretendIsKeyWindow:NO];
184 [window_ makeFirstResponder:nil]; 184 [window_ makeFirstResponder:nil];
185 } 185 }
186 186
187 private: 187 private:
188 scoped_nsobject<CocoaTestHelperWindow> window_; 188 scoped_nsobject<CocoaTestHelperWindow> window_;
189 }; 189 };
190 190
191 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ 191 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698