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

Unified Diff: ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm

Issue 2677523002: [ObjC ARC] Converts ios/chrome/browser/ui/context_menu:unit_tests to ARC. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/context_menu/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm
diff --git a/ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm b/ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm
index 5ef3dac4a8d6663f3e6ed7a6983f09b8711ca4a7..2b58812578de2d0086a8f43a5e038b455e74494a 100644
--- a/ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm
+++ b/ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm
@@ -7,22 +7,23 @@
#import <UIKit/UIKit.h>
#import "base/mac/foundation_util.h"
-#import "base/mac/scoped_nsobject.h"
#import "ios/web/public/web_state/context_menu_params.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
// Fixture to test ContextMenuCoordinator.
class ContextMenuCoordinatorTest : public PlatformTest {
public:
ContextMenuCoordinatorTest() {
// Save the current key window and restore it after the test.
- previous_key_window_.reset(
- [[[UIApplication sharedApplication] keyWindow] retain]);
- window_.reset(
- [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]);
+ previous_key_window_ = [[UIApplication sharedApplication] keyWindow];
+ window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window_ makeKeyAndVisible];
- view_controller_.reset([[UIViewController alloc] init]);
+ view_controller_ = [[UIViewController alloc] init];
[window_ setRootViewController:view_controller_];
}
@@ -31,20 +32,20 @@ class ContextMenuCoordinatorTest : public PlatformTest {
}
protected:
- base::scoped_nsobject<UIWindow> previous_key_window_;
- base::scoped_nsobject<ContextMenuCoordinator> menu_coordinator_;
- base::scoped_nsobject<UIWindow> window_;
- base::scoped_nsobject<UIViewController> view_controller_;
+ UIWindow* previous_key_window_;
+ ContextMenuCoordinator* menu_coordinator_;
+ UIWindow* window_;
+ UIViewController* view_controller_;
};
// Tests the context menu reports as visible after presenting.
TEST_F(ContextMenuCoordinatorTest, ValidateIsVisible) {
web::ContextMenuParams params;
params.location = CGPointZero;
- params.view.reset([[view_controller_ view] retain]);
- menu_coordinator_.reset([[ContextMenuCoordinator alloc]
+ params.view.reset([view_controller_ view]);
+ menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
- params:params]);
+ params:params];
[menu_coordinator_ start];
EXPECT_TRUE([menu_coordinator_ isVisible]);
@@ -54,10 +55,10 @@ TEST_F(ContextMenuCoordinatorTest, ValidateIsVisible) {
TEST_F(ContextMenuCoordinatorTest, ValidateDismissalOnStop) {
web::ContextMenuParams params;
params.location = CGPointZero;
- params.view.reset([[view_controller_ view] retain]);
- menu_coordinator_.reset([[ContextMenuCoordinator alloc]
+ params.view.reset([view_controller_ view]);
+ menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
- params:params]);
+ params:params];
[menu_coordinator_ start];
[menu_coordinator_ stop];
@@ -69,10 +70,10 @@ TEST_F(ContextMenuCoordinatorTest, ValidateDismissalOnStop) {
TEST_F(ContextMenuCoordinatorTest, ValidateActions) {
web::ContextMenuParams params;
params.location = CGPointZero;
- params.view.reset([[view_controller_ view] retain]);
- menu_coordinator_.reset([[ContextMenuCoordinator alloc]
+ params.view.reset([view_controller_ view]);
+ menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
- params:params]);
+ params:params];
NSArray* menu_titles = @[ @"foo", @"bar" ];
for (NSString* title in menu_titles) {
@@ -89,8 +90,7 @@ TEST_F(ContextMenuCoordinatorTest, ValidateActions) {
base::mac::ObjCCastStrict<UIAlertController>(
[view_controller_ presentedViewController]);
- base::scoped_nsobject<NSMutableArray> remaining_titles(
- [menu_titles mutableCopy]);
+ NSMutableArray* remaining_titles = [menu_titles mutableCopy];
for (UIAlertAction* action in alert_controller.actions) {
if (action.style != UIAlertActionStyleCancel) {
EXPECT_TRUE([remaining_titles containsObject:action.title]);
@@ -105,10 +105,10 @@ TEST_F(ContextMenuCoordinatorTest, ValidateActions) {
TEST_F(ContextMenuCoordinatorTest, CancelButtonExists) {
web::ContextMenuParams params;
params.location = CGPointZero;
- params.view.reset([[view_controller_ view] retain]);
- menu_coordinator_.reset([[ContextMenuCoordinator alloc]
+ params.view.reset([view_controller_ view]);
+ menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
- params:params]);
+ params:params];
[menu_coordinator_ start];
@@ -131,10 +131,10 @@ TEST_F(ContextMenuCoordinatorTest, ValidateContextMenuParams) {
web::ContextMenuParams params;
params.location = location;
params.menu_title.reset(title);
- params.view.reset([[view_controller_ view] retain]);
- menu_coordinator_.reset([[ContextMenuCoordinator alloc]
+ params.view.reset([view_controller_ view]);
+ menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
- params:params]);
+ params:params];
[menu_coordinator_ start];
EXPECT_TRUE([[view_controller_ presentedViewController]
« no previous file with comments | « ios/chrome/browser/ui/context_menu/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698