Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 { |
|
sdefresne
2017/04/27 13:40:58
Please add the missing call to PlatformTest::SetUp
gambard
2017/04/27 14:58:22
Done.
| |
| 34 toolbarController_.reset([[ToolbarController alloc] | 37 toolbarController_ = [[ToolbarController alloc] |
| 35 initWithStyle:ToolbarControllerStyleLightMode]); | 38 initWithStyle:ToolbarControllerStyleLightMode]; |
| 36 } | 39 } |
| 37 | 40 |
| 38 base::scoped_nsobject<ToolbarController> toolbarController_; | 41 ToolbarController* toolbarController_; |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 // Verify that if tab count is set to zero, the title is blank, but the a11y | 44 // Verify that if tab count is set to zero, the title is blank, but the a11y |
| 42 // value is 0. | 45 // value is 0. |
| 43 // | 46 // |
| 44 // Note that the iPad doesn't have a |stackButton|, but setTabCount may still | 47 // 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 | 48 // 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. | 49 // tests don't do anything if run on an iPad. |
| 47 TEST_F(ToolbarControllerTest, TestTabCountZero) { | 50 TEST_F(ToolbarControllerTest, TestTabCountZero) { |
| 48 // On iPad, there is no |stackButton|, so the title should be NULL. | 51 // On iPad, there is no |stackButton|, so the title should be NULL. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 [toolbarController_ setTabCount:kStackButtonEasterEggTabCount]; | 85 [toolbarController_ setTabCount:kStackButtonEasterEggTabCount]; |
| 83 EXPECT_NSEQ(kStackButtonEasterEggString, | 86 EXPECT_NSEQ(kStackButtonEasterEggString, |
| 84 [toolbarController_ stackButton].currentTitle); | 87 [toolbarController_ stackButton].currentTitle); |
| 85 | 88 |
| 86 [toolbarController_ setTabCount:kStackButtonMaxTabCount]; | 89 [toolbarController_ setTabCount:kStackButtonMaxTabCount]; |
| 87 EXPECT_NSEQ(kStackButtonMaxTabCountString, | 90 EXPECT_NSEQ(kStackButtonMaxTabCountString, |
| 88 [toolbarController_ stackButton].currentTitle); | 91 [toolbarController_ stackButton].currentTitle); |
| 89 } | 92 } |
| 90 | 93 |
| 91 } // namespace | 94 } // namespace |
| OLD | NEW |