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

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

Issue 2588733002: Upstream Chrome on iOS source code [9/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <Foundation/Foundation.h>
6
7 #include "base/format_macros.h"
8 #include "base/mac/scoped_nsobject.h"
9 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h"
10 #import "ios/chrome/browser/ui/toolbar/toolbar_controller_private.h"
11 #import "ios/chrome/browser/ui/ui_util.h"
12 #include "testing/gtest_mac.h"
13 #include "testing/platform_test.h"
14
15 // A constant holding some number of tabs that will trigger an easter egg.
16 const NSInteger kStackButtonEasterEggTabCount = kStackButtonMaxTabCount + 1;
17
18 // The easter egg string.
19 NSString* kStackButtonEasterEggString = @":)";
20
21 // Strings containing the max tab count and easter egg tab counts.
22 NSString* kStackButtonMaxTabCountString =
23 [NSString stringWithFormat:@"%" PRIdNS, kStackButtonMaxTabCount];
24 NSString* kStackButtonEasterEggTabCountString =
25 [NSString stringWithFormat:@"%" PRIdNS, kStackButtonEasterEggTabCount];
26
27 #pragma mark -
28
29 namespace {
30
31 class ToolbarControllerTest : public PlatformTest {
32 protected:
33 void SetUp() override {
34 toolbarController_.reset([[ToolbarController alloc]
35 initWithStyle:ToolbarControllerStyleLightMode]);
36 }
37
38 base::scoped_nsobject<ToolbarController> toolbarController_;
39 };
40
41 // Verify that if tab count is set to zero, the title is blank, but the a11y
42 // value is 0.
43 //
44 // 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
46 // tests don't do anything if run on an iPad.
47 TEST_F(ToolbarControllerTest, TestTabCountZero) {
48 // On iPad, there is no |stackButton|, so the title should be NULL.
49 NSString* expectedTitle = IsIPadIdiom() ? NULL : @"";
50
51 [toolbarController_ setTabCount:0];
52 EXPECT_NSEQ(expectedTitle, [toolbarController_ stackButton].currentTitle);
53 }
54
55 // Verify that when subsequent calls to tab count cross the max tab count
56 // threshhold (increasing), the title is blank but the a11y value is set to the
57 // second value.
58 //
59 // Doesn't do anything when run on an iPad.
60 TEST_F(ToolbarControllerTest, TestTabCountBecomesEasterEgg_iPhoneOnly) {
61 if (IsIPadIdiom())
62 return;
63
64 [toolbarController_ setTabCount:kStackButtonMaxTabCount];
65 EXPECT_NSEQ(kStackButtonMaxTabCountString,
66 [toolbarController_ stackButton].currentTitle);
67
68 [toolbarController_ setTabCount:kStackButtonEasterEggTabCount];
69 EXPECT_NSEQ(kStackButtonEasterEggString,
70 [toolbarController_ stackButton].currentTitle);
71 }
72
73 // Verify that when subsequent calls to tab count cross the max tab count
74 // threshhold (decreasing), title and a11y value are both set to the second
75 // value.
76 //
77 // Doesn't do anything when run on an iPad.
78 TEST_F(ToolbarControllerTest, TestTabCountStopsBeingEasterEgg_iPhoneOnly) {
79 if (IsIPadIdiom())
80 return;
81
82 [toolbarController_ setTabCount:kStackButtonEasterEggTabCount];
83 EXPECT_NSEQ(kStackButtonEasterEggString,
84 [toolbarController_ stackButton].currentTitle);
85
86 [toolbarController_ setTabCount:kStackButtonMaxTabCount];
87 EXPECT_NSEQ(kStackButtonMaxTabCountString,
88 [toolbarController_ stackButton].currentTitle);
89 }
90
91 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/toolbar/toolbar_controller_private.h ('k') | ios/chrome/browser/ui/toolbar/toolbar_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698