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

Side by Side Diff: ios/chrome/browser/ui/toolbar/toolbar_controller_unittest.mm

Issue 2835413003: [ObjC ARC] Converts ios/chrome/browser/ui/toolbar:unit_tests to ARC. (Closed)
Patch Set: Address comments 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/mac/scoped_nsobject.h"
9 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" 8 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h"
10 #import "ios/chrome/browser/ui/toolbar/toolbar_controller_private.h" 9 #import "ios/chrome/browser/ui/toolbar/toolbar_controller_private.h"
11 #import "ios/chrome/browser/ui/ui_util.h" 10 #import "ios/chrome/browser/ui/ui_util.h"
12 #include "testing/gtest_mac.h" 11 #include "testing/gtest_mac.h"
13 #include "testing/platform_test.h" 12 #include "testing/platform_test.h"
14 13
14 #if !defined(__has_feature) || !__has_feature(objc_arc)
15 #error "This file requires ARC support."
16 #endif
17
15 // A constant holding some number of tabs that will trigger an easter egg. 18 // A constant holding some number of tabs that will trigger an easter egg.
16 const NSInteger kStackButtonEasterEggTabCount = kStackButtonMaxTabCount + 1; 19 const NSInteger kStackButtonEasterEggTabCount = kStackButtonMaxTabCount + 1;
17 20
18 // The easter egg string. 21 // The easter egg string.
19 NSString* kStackButtonEasterEggString = @":)"; 22 NSString* kStackButtonEasterEggString = @":)";
20 23
21 // Strings containing the max tab count and easter egg tab counts. 24 // Strings containing the max tab count and easter egg tab counts.
22 NSString* kStackButtonMaxTabCountString = 25 NSString* kStackButtonMaxTabCountString =
23 [NSString stringWithFormat:@"%" PRIdNS, kStackButtonMaxTabCount]; 26 [NSString stringWithFormat:@"%" PRIdNS, kStackButtonMaxTabCount];
24 NSString* kStackButtonEasterEggTabCountString = 27 NSString* kStackButtonEasterEggTabCountString =
25 [NSString stringWithFormat:@"%" PRIdNS, kStackButtonEasterEggTabCount]; 28 [NSString stringWithFormat:@"%" PRIdNS, kStackButtonEasterEggTabCount];
26 29
27 #pragma mark - 30 #pragma mark -
28 31
29 namespace { 32 namespace {
30 33
31 class ToolbarControllerTest : public PlatformTest { 34 class ToolbarControllerTest : public PlatformTest {
32 protected: 35 protected:
33 void SetUp() override { 36 void SetUp() override {
34 toolbarController_.reset([[ToolbarController alloc] 37 PlatformTest::SetUp();
35 initWithStyle:ToolbarControllerStyleLightMode]); 38 toolbarController_ = [[ToolbarController alloc]
39 initWithStyle:ToolbarControllerStyleLightMode];
36 } 40 }
37 41
38 base::scoped_nsobject<ToolbarController> toolbarController_; 42 ToolbarController* toolbarController_;
39 }; 43 };
40 44
41 // Verify that if tab count is set to zero, the title is blank, but the a11y 45 // Verify that if tab count is set to zero, the title is blank, but the a11y
42 // value is 0. 46 // value is 0.
43 // 47 //
44 // Note that the iPad doesn't have a |stackButton|, but setTabCount may still 48 // Note that the iPad doesn't have a |stackButton|, but setTabCount may still
45 // be invoked so this test covers that code path. The rest of the tab count 49 // be invoked so this test covers that code path. The rest of the tab count
46 // tests don't do anything if run on an iPad. 50 // tests don't do anything if run on an iPad.
47 TEST_F(ToolbarControllerTest, TestTabCountZero) { 51 TEST_F(ToolbarControllerTest, TestTabCountZero) {
48 // On iPad, there is no |stackButton|, so the title should be NULL. 52 // On iPad, there is no |stackButton|, so the title should be NULL.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 [toolbarController_ setTabCount:kStackButtonEasterEggTabCount]; 86 [toolbarController_ setTabCount:kStackButtonEasterEggTabCount];
83 EXPECT_NSEQ(kStackButtonEasterEggString, 87 EXPECT_NSEQ(kStackButtonEasterEggString,
84 [toolbarController_ stackButton].currentTitle); 88 [toolbarController_ stackButton].currentTitle);
85 89
86 [toolbarController_ setTabCount:kStackButtonMaxTabCount]; 90 [toolbarController_ setTabCount:kStackButtonMaxTabCount];
87 EXPECT_NSEQ(kStackButtonMaxTabCountString, 91 EXPECT_NSEQ(kStackButtonMaxTabCountString,
88 [toolbarController_ stackButton].currentTitle); 92 [toolbarController_ stackButton].currentTitle);
89 } 93 }
90 94
91 } // namespace 95 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/toolbar/BUILD.gn ('k') | ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698