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

Side by Side Diff: ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller_unittest.mm

Issue 2888423002: [ObjC ARC] Converts ios/chrome/browser/ui/first_run:unit_tests to ARC. (Closed)
Patch Set: Created 3 years, 7 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/first_run/first_run_util_unittest.mm ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/mac/scoped_nsobject.h"
10 #include "components/metrics/metrics_pref_names.h" 9 #include "components/metrics/metrics_pref_names.h"
11 #include "components/prefs/pref_registry_simple.h" 10 #include "components/prefs/pref_registry_simple.h"
12 #include "components/prefs/testing_pref_service.h" 11 #include "components/prefs/testing_pref_service.h"
13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
14 #include "ios/chrome/browser/tabs/tab_model.h" 13 #include "ios/chrome/browser/tabs/tab_model.h"
15 #include "ios/chrome/browser/ui/fancy_ui/primary_action_button.h" 14 #include "ios/chrome/browser/ui/fancy_ui/primary_action_button.h"
16 #import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view.h" 15 #import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view.h"
17 #import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller.h" 16 #import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller.h"
18 #include "ios/chrome/browser/ui/ui_util.h" 17 #include "ios/chrome/browser/ui/ui_util.h"
19 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" 18 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
20 #include "ios/web/public/test/test_web_thread_bundle.h" 19 #include "ios/web/public/test/test_web_thread_bundle.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/gtest_mac.h" 21 #include "testing/gtest_mac.h"
23 #include "testing/platform_test.h" 22 #include "testing/platform_test.h"
24 #include "third_party/ocmock/OCMock/OCMock.h" 23 #include "third_party/ocmock/OCMock/OCMock.h"
25 #include "third_party/ocmock/gtest_support.h" 24 #include "third_party/ocmock/gtest_support.h"
26 25
26 #if !defined(__has_feature) || !__has_feature(objc_arc)
27 #error "This file requires ARC support."
28 #endif
29
27 @interface WelcomeToChromeView (ExposedForTesting) 30 @interface WelcomeToChromeView (ExposedForTesting)
28 @property(nonatomic, retain, readonly) UIButton* checkBoxButton; 31 @property(nonatomic, retain, readonly) UIButton* checkBoxButton;
29 - (void)checkBoxButtonWasTapped; 32 - (void)checkBoxButtonWasTapped;
30 @end 33 @end
31 34
32 namespace { 35 namespace {
33 36
34 class WelcomeToChromeViewControllerTest : public PlatformTest { 37 class WelcomeToChromeViewControllerTest : public PlatformTest {
35 protected: 38 protected:
36 void SetUp() override { 39 void SetUp() override {
37 PlatformTest::SetUp(); 40 PlatformTest::SetUp();
38 TestChromeBrowserState::Builder test_cbs_builder; 41 TestChromeBrowserState::Builder test_cbs_builder;
39 chrome_browser_state_ = test_cbs_builder.Build(); 42 chrome_browser_state_ = test_cbs_builder.Build();
40 id tabModel = [OCMockObject mockForClass:[TabModel class]]; 43 id tabModel = [OCMockObject mockForClass:[TabModel class]];
41 controller_.reset([[WelcomeToChromeViewController alloc] 44 controller_ = [[WelcomeToChromeViewController alloc]
42 initWithBrowserState:chrome_browser_state_.get() 45 initWithBrowserState:chrome_browser_state_.get()
43 tabModel:tabModel]); 46 tabModel:tabModel];
44 [controller_ loadView]; 47 [controller_ loadView];
45 } 48 }
46 49
47 void TearDown() override { 50 void TearDown() override {
48 controller_.reset(); 51 controller_ = nil;
49 PlatformTest::TearDown(); 52 PlatformTest::TearDown();
50 } 53 }
51 54
52 web::TestWebThreadBundle thread_bundle_; 55 web::TestWebThreadBundle thread_bundle_;
53 IOSChromeScopedTestingLocalState local_state_; 56 IOSChromeScopedTestingLocalState local_state_;
54 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 57 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
55 base::scoped_nsobject<WelcomeToChromeViewController> controller_; 58 WelcomeToChromeViewController* controller_;
56 }; 59 };
57 60
58 TEST_F(WelcomeToChromeViewControllerTest, TestDefaultStatsCheckBoxValue) { 61 TEST_F(WelcomeToChromeViewControllerTest, TestDefaultStatsCheckBoxValue) {
59 BOOL checkbox_value = 62 BOOL checkbox_value =
60 [WelcomeToChromeViewController defaultStatsCheckboxValue]; 63 [WelcomeToChromeViewController defaultStatsCheckboxValue];
61 ASSERT_TRUE(checkbox_value); 64 ASSERT_TRUE(checkbox_value);
62 } 65 }
63 66
64 TEST_F(WelcomeToChromeViewControllerTest, TestConstructorDestructor) { 67 TEST_F(WelcomeToChromeViewControllerTest, TestConstructorDestructor) {
65 EXPECT_TRUE(controller_.get()); 68 EXPECT_TRUE(controller_);
66 EXPECT_TRUE([controller_ view]); 69 EXPECT_TRUE([controller_ view]);
67 } 70 }
68 71
69 TEST_F(WelcomeToChromeViewControllerTest, TestToggleCheckbox) { 72 TEST_F(WelcomeToChromeViewControllerTest, TestToggleCheckbox) {
70 WelcomeToChromeView* welcome_view = 73 WelcomeToChromeView* welcome_view =
71 static_cast<WelcomeToChromeView*>([controller_ view]); 74 static_cast<WelcomeToChromeView*>([controller_ view]);
72 EXPECT_TRUE(welcome_view.checkBoxButton.selected); 75 EXPECT_TRUE(welcome_view.checkBoxButton.selected);
73 [welcome_view checkBoxButtonWasTapped]; 76 [welcome_view checkBoxButtonWasTapped];
74 EXPECT_FALSE(welcome_view.checkBoxButton.selected); 77 EXPECT_FALSE(welcome_view.checkBoxButton.selected);
75 [welcome_view checkBoxButtonWasTapped]; 78 [welcome_view checkBoxButtonWasTapped];
76 EXPECT_TRUE(welcome_view.checkBoxButton.selected); 79 EXPECT_TRUE(welcome_view.checkBoxButton.selected);
77 } 80 }
78 81
79 } // namespace 82 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/first_run/first_run_util_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698