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

Side by Side Diff: ios/chrome/browser/ui/browser_container_view_unittest.mm

Issue 2936833002: [ObjC ARC] Converts ios/chrome/browser/ui:unit_tests to ARC. (Closed)
Patch Set: Fix bad ARC guard. 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "ios/chrome/browser/ui/browser_container_view.h" 5 #import "ios/chrome/browser/ui/browser_container_view.h"
6 6
7 #import "base/mac/scoped_nsobject.h"
8 #include "testing/platform_test.h" 7 #include "testing/platform_test.h"
9 8
9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support."
11 #endif
12
10 // Fixture for BrowserContainerView testing. 13 // Fixture for BrowserContainerView testing.
11 class BrowserContainerViewTest : public PlatformTest { 14 class BrowserContainerViewTest : public PlatformTest {
12 protected: 15 protected:
13 void SetUp() override { 16 void SetUp() override {
14 PlatformTest::SetUp(); 17 PlatformTest::SetUp();
15 18
16 browser_container_view_.reset([[BrowserContainerView alloc] init]); 19 browser_container_view_ = [[BrowserContainerView alloc] init];
17 ASSERT_TRUE(browser_container_view_); 20 ASSERT_TRUE(browser_container_view_);
18 content_view_.reset([[UIView alloc] init]); 21 content_view_ = [[UIView alloc] init];
19 ASSERT_TRUE(content_view_); 22 ASSERT_TRUE(content_view_);
20 } 23 }
21 base::scoped_nsobject<BrowserContainerView> browser_container_view_; 24 BrowserContainerView* browser_container_view_;
22 base::scoped_nsobject<UIView> content_view_; 25 UIView* content_view_;
23 }; 26 };
24 27
25 // Tests adding a new content view when BrowserContainerView does not currently 28 // Tests adding a new content view when BrowserContainerView does not currently
26 // have a content view. 29 // have a content view.
27 TEST_F(BrowserContainerViewTest, AddingContentView) { 30 TEST_F(BrowserContainerViewTest, AddingContentView) {
28 ASSERT_FALSE([content_view_ superview]); 31 ASSERT_FALSE([content_view_ superview]);
29 32
30 [browser_container_view_ displayContentView:content_view_]; 33 [browser_container_view_ displayContentView:content_view_];
31 EXPECT_EQ(static_cast<UIView*>(browser_container_view_), 34 EXPECT_EQ(static_cast<UIView*>(browser_container_view_),
32 [content_view_ superview]); 35 [content_view_ superview]);
33 } 36 }
34 37
35 // Tests removing previously added content view. 38 // Tests removing previously added content view.
36 TEST_F(BrowserContainerViewTest, RemovingContentView) { 39 TEST_F(BrowserContainerViewTest, RemovingContentView) {
37 [browser_container_view_ displayContentView:content_view_]; 40 [browser_container_view_ displayContentView:content_view_];
38 ASSERT_EQ(static_cast<UIView*>(browser_container_view_), 41 ASSERT_EQ(static_cast<UIView*>(browser_container_view_),
39 [content_view_ superview]); 42 [content_view_ superview]);
40 43
41 [browser_container_view_ displayContentView:nil]; 44 [browser_container_view_ displayContentView:nil];
42 EXPECT_FALSE([content_view_ superview]); 45 EXPECT_FALSE([content_view_ superview]);
43 } 46 }
44 47
45 // Tests adding a new content view when BrowserContainerView already has a 48 // Tests adding a new content view when BrowserContainerView already has a
46 // content view. 49 // content view.
47 TEST_F(BrowserContainerViewTest, ReplacingContentView) { 50 TEST_F(BrowserContainerViewTest, ReplacingContentView) {
48 [browser_container_view_ displayContentView:content_view_]; 51 [browser_container_view_ displayContentView:content_view_];
49 ASSERT_EQ(static_cast<UIView*>(browser_container_view_), 52 ASSERT_EQ(static_cast<UIView*>(browser_container_view_),
50 [content_view_ superview]); 53 [content_view_ superview]);
51 54
52 base::scoped_nsobject<UIView> content_view2([[UIView alloc] init]); 55 UIView* content_view2 = [[UIView alloc] init];
53 [browser_container_view_ displayContentView:content_view2]; 56 [browser_container_view_ displayContentView:content_view2];
54 EXPECT_FALSE([content_view_ superview]); 57 EXPECT_FALSE([content_view_ superview]);
55 EXPECT_EQ(static_cast<UIView*>(browser_container_view_), 58 EXPECT_EQ(static_cast<UIView*>(browser_container_view_),
56 [content_view2 superview]); 59 [content_view2 superview]);
57 } 60 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/BUILD.gn ('k') | ios/chrome/browser/ui/browser_view_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698