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

Side by Side Diff: ios/chrome/test/scoped_key_window.h

Issue 2932273003: [ObjC ARC] Converts ios/chrome/test:test_support to ARC. (Closed)
Patch Set: Review feedback. Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 IOS_CHROME_TEST_SCOPED_KEY_WINDOW_H_ 5 #ifndef IOS_CHROME_TEST_SCOPED_KEY_WINDOW_H_
6 #define IOS_CHROME_TEST_SCOPED_KEY_WINDOW_H_ 6 #define IOS_CHROME_TEST_SCOPED_KEY_WINDOW_H_
7 7
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 // Sets temporary key window and returns it via Get method. Saves the current 10 // Sets temporary key window and returns it via Get method. Saves the current
11 // key window and restores it on destruction. 11 // key window and restores it on destruction.
12 class ScopedKeyWindow { 12 class ScopedKeyWindow {
13 public: 13 public:
14 explicit ScopedKeyWindow() 14 explicit ScopedKeyWindow()
15 : current_key_window_( 15 : current_key_window_(
16 [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]), 16 [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]),
17 original_key_window_([UIApplication sharedApplication].keyWindow) { 17 original_key_window_([UIApplication sharedApplication].keyWindow) {
18 [current_key_window_ makeKeyAndVisible]; 18 [current_key_window_ makeKeyAndVisible];
19 } 19 }
20 ~ScopedKeyWindow() { [original_key_window_ makeKeyAndVisible]; } 20 ~ScopedKeyWindow() { [original_key_window_ makeKeyAndVisible]; }
21 UIWindow* Get() { return current_key_window_; } 21 UIWindow* Get() { return current_key_window_; }
22 22
23 private: 23 private:
24 UIWindow* current_key_window_; 24 __strong UIWindow* current_key_window_;
25 UIWindow* original_key_window_; 25 __strong UIWindow* original_key_window_;
26 }; 26 };
27 27
28 #endif // IOS_CHROME_TEST_SCOPED_KEY_WINDOW_H_ 28 #endif // IOS_CHROME_TEST_SCOPED_KEY_WINDOW_H_
OLDNEW
« no previous file with comments | « ios/chrome/test/ios_chrome_unit_test_suite.mm ('k') | ios/chrome/test/testing_application_context.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698