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

Side by Side Diff: ios/chrome/browser/ui/promos/signin_promo_view_controller_unittest.mm

Issue 2688703004: [ObjC ARC] Converts ios/chrome/browser/ui/promos:unit_tests to ARC. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ios/chrome/browser/ui/promos/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #import "base/mac/scoped_nsobject.h"
10 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
11 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
12 #include "base/version.h" 11 #include "base/version.h"
13 #include "components/pref_registry/pref_registry_syncable.h" 12 #include "components/pref_registry/pref_registry_syncable.h"
14 #include "components/sync_preferences/pref_service_mock_factory.h" 13 #include "components/sync_preferences/pref_service_mock_factory.h"
15 #include "components/sync_preferences/pref_service_syncable.h" 14 #include "components/sync_preferences/pref_service_syncable.h"
16 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
17 #include "ios/chrome/browser/prefs/browser_prefs.h" 16 #include "ios/chrome/browser/prefs/browser_prefs.h"
18 #include "ios/chrome/browser/signin/authentication_service_factory.h" 17 #include "ios/chrome/browser/signin/authentication_service_factory.h"
19 #import "ios/chrome/browser/signin/authentication_service_fake.h" 18 #import "ios/chrome/browser/signin/authentication_service_fake.h"
20 #import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h" 19 #import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h"
21 #include "ios/chrome/test/block_cleanup_test.h" 20 #include "ios/chrome/test/block_cleanup_test.h"
22 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service. h" 21 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service. h"
23 #include "ios/web/public/test/test_web_thread_bundle.h" 22 #include "ios/web/public/test/test_web_thread_bundle.h"
24 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
25 #import "third_party/ocmock/OCMock/OCMock.h" 24 #import "third_party/ocmock/OCMock/OCMock.h"
26 #import "third_party/ocmock/gtest_support.h" 25 #import "third_party/ocmock/gtest_support.h"
27 26
27 #if !defined(__has_feature) || !__has_feature(objc_arc)
28 #error "This file requires ARC support."
29 #endif
30
28 @interface SigninPromoViewController (ExposedForTesting) 31 @interface SigninPromoViewController (ExposedForTesting)
29 @property(nonatomic, readonly) UIView* accountsContainer; 32 @property(nonatomic, readonly) UIView* accountsContainer;
30 - (void)recordPromoDisplayed; 33 - (void)recordPromoDisplayed;
31 + (base::Version)currentVersion; 34 + (base::Version)currentVersion;
32 @end 35 @end
33 36
34 namespace { 37 namespace {
35 // Fake version used in tests. 38 // Fake version used in tests.
36 base::Version* gFakeCurrentVersion = nullptr; 39 base::Version* gFakeCurrentVersion = nullptr;
37 } 40 }
(...skipping 26 matching lines...) Expand all
64 67
65 enum ButtonTestingID { 68 enum ButtonTestingID {
66 // IBUITag specified in the .xib file. 69 // IBUITag specified in the .xib file.
67 FRONT_CLOSE_BUTTON_ID = 202, 70 FRONT_CLOSE_BUTTON_ID = 202,
68 }; 71 };
69 72
70 class SigninPromoViewControllerTest : public BlockCleanupTest { 73 class SigninPromoViewControllerTest : public BlockCleanupTest {
71 public: 74 public:
72 ~SigninPromoViewControllerTest() override {} 75 ~SigninPromoViewControllerTest() override {}
73 76
74 SigninPromoViewController* controller() { return controller_.get(); } 77 SigninPromoViewController* controller() { return controller_; }
75 78
76 void SetUp() override { 79 void SetUp() override {
77 BlockCleanupTest::SetUp(); 80 BlockCleanupTest::SetUp();
78 [FakeVersionSigninPromoViewController setFakeCurrentVersion:"1.0"]; 81 [FakeVersionSigninPromoViewController setFakeCurrentVersion:"1.0"];
79 TestChromeBrowserState::Builder builder; 82 TestChromeBrowserState::Builder builder;
80 builder.SetPrefService(CreatePrefService()); 83 builder.SetPrefService(CreatePrefService());
81 builder.AddTestingFactory( 84 builder.AddTestingFactory(
82 AuthenticationServiceFactory::GetInstance(), 85 AuthenticationServiceFactory::GetInstance(),
83 AuthenticationServiceFake::CreateAuthenticationService); 86 AuthenticationServiceFake::CreateAuthenticationService);
84 chrome_browser_state_ = builder.Build(); 87 chrome_browser_state_ = builder.Build();
85 ios::FakeChromeIdentityService::GetInstanceFromChromeProvider() 88 ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()
86 ->AddIdentities(@[ @"foo", @"bar" ]); 89 ->AddIdentities(@[ @"foo", @"bar" ]);
87 controller_.reset([[FakeVersionSigninPromoViewController alloc] 90 controller_ = [[FakeVersionSigninPromoViewController alloc]
88 initWithBrowserState:chrome_browser_state_.get()]); 91 initWithBrowserState:chrome_browser_state_.get()];
89 } 92 }
90 93
91 void TearDown() override { 94 void TearDown() override {
92 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; 95 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
93 [standardDefaults removeObjectForKey:kDisplayedSSORecallForMajorVersionKey]; 96 [standardDefaults removeObjectForKey:kDisplayedSSORecallForMajorVersionKey];
94 [standardDefaults synchronize]; 97 [standardDefaults synchronize];
95 [FakeVersionSigninPromoViewController clearFakeCurrentVersion]; 98 [FakeVersionSigninPromoViewController clearFakeCurrentVersion];
96 BlockCleanupTest::TearDown(); 99 BlockCleanupTest::TearDown();
97 } 100 }
98 101
(...skipping 11 matching lines...) Expand all
110 SigninPromoViewController* signin_promo_view_controller = 113 SigninPromoViewController* signin_promo_view_controller =
111 static_cast<SigninPromoViewController*>(controller()); 114 static_cast<SigninPromoViewController*>(controller());
112 EXPECT_TRUE([signin_promo_view_controller 115 EXPECT_TRUE([signin_promo_view_controller
113 isKindOfClass:[SigninPromoViewController class]]); 116 isKindOfClass:[SigninPromoViewController class]]);
114 [signin_promo_view_controller recordPromoDisplayed]; 117 [signin_promo_view_controller recordPromoDisplayed];
115 } 118 }
116 119
117 protected: 120 protected:
118 web::TestWebThreadBundle thread_bundle_; 121 web::TestWebThreadBundle thread_bundle_;
119 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 122 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
120 base::scoped_nsobject<SigninPromoViewController> controller_; 123 SigninPromoViewController* controller_;
121 }; 124 };
122 125
123 TEST_F(SigninPromoViewControllerTest, TestConstructorDestructor) { 126 TEST_F(SigninPromoViewControllerTest, TestConstructorDestructor) {
124 EXPECT_TRUE(controller()); 127 EXPECT_TRUE(controller());
125 EXPECT_TRUE([controller() view]); 128 EXPECT_TRUE([controller() view]);
126 } 129 }
127 130
128 TEST_F(SigninPromoViewControllerTest, TestWillDisplay) { 131 TEST_F(SigninPromoViewControllerTest, TestWillDisplay) {
129 EXPECT_TRUE([SigninPromoViewController 132 EXPECT_TRUE([SigninPromoViewController
130 shouldBePresentedForBrowserState:chrome_browser_state_.get()]); 133 shouldBePresentedForBrowserState:chrome_browser_state_.get()]);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 165
163 TEST_F(SigninPromoViewControllerTest, TestWillDisplayTwoMajorVersions) { 166 TEST_F(SigninPromoViewControllerTest, TestWillDisplayTwoMajorVersions) {
164 SetPromoHasBeenShown(); 167 SetPromoHasBeenShown();
165 // Set the future version to be two major releases ahead. 168 // Set the future version to be two major releases ahead.
166 [FakeVersionSigninPromoViewController setFakeCurrentVersion:"3.0"]; 169 [FakeVersionSigninPromoViewController setFakeCurrentVersion:"3.0"];
167 EXPECT_TRUE([FakeVersionSigninPromoViewController 170 EXPECT_TRUE([FakeVersionSigninPromoViewController
168 shouldBePresentedForBrowserState:chrome_browser_state_.get()]); 171 shouldBePresentedForBrowserState:chrome_browser_state_.get()]);
169 } 172 }
170 173
171 } // namespace 174 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/promos/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698