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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/toolbar/toolbar_controller_unittest.mm
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_controller_unittest.mm b/ios/chrome/browser/ui/toolbar/toolbar_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..1e7fe9533b8a7fffc9b205323950c4cbf016fdbf
--- /dev/null
+++ b/ios/chrome/browser/ui/toolbar/toolbar_controller_unittest.mm
@@ -0,0 +1,91 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Foundation/Foundation.h>
+
+#include "base/format_macros.h"
+#include "base/mac/scoped_nsobject.h"
+#import "ios/chrome/browser/ui/toolbar/toolbar_controller.h"
+#import "ios/chrome/browser/ui/toolbar/toolbar_controller_private.h"
+#import "ios/chrome/browser/ui/ui_util.h"
+#include "testing/gtest_mac.h"
+#include "testing/platform_test.h"
+
+// A constant holding some number of tabs that will trigger an easter egg.
+const NSInteger kStackButtonEasterEggTabCount = kStackButtonMaxTabCount + 1;
+
+// The easter egg string.
+NSString* kStackButtonEasterEggString = @":)";
+
+// Strings containing the max tab count and easter egg tab counts.
+NSString* kStackButtonMaxTabCountString =
+ [NSString stringWithFormat:@"%" PRIdNS, kStackButtonMaxTabCount];
+NSString* kStackButtonEasterEggTabCountString =
+ [NSString stringWithFormat:@"%" PRIdNS, kStackButtonEasterEggTabCount];
+
+#pragma mark -
+
+namespace {
+
+class ToolbarControllerTest : public PlatformTest {
+ protected:
+ void SetUp() override {
+ toolbarController_.reset([[ToolbarController alloc]
+ initWithStyle:ToolbarControllerStyleLightMode]);
+ }
+
+ base::scoped_nsobject<ToolbarController> toolbarController_;
+};
+
+// Verify that if tab count is set to zero, the title is blank, but the a11y
+// value is 0.
+//
+// Note that the iPad doesn't have a |stackButton|, but setTabCount may still
+// be invoked so this test covers that code path. The rest of the tab count
+// tests don't do anything if run on an iPad.
+TEST_F(ToolbarControllerTest, TestTabCountZero) {
+ // On iPad, there is no |stackButton|, so the title should be NULL.
+ NSString* expectedTitle = IsIPadIdiom() ? NULL : @"";
+
+ [toolbarController_ setTabCount:0];
+ EXPECT_NSEQ(expectedTitle, [toolbarController_ stackButton].currentTitle);
+}
+
+// Verify that when subsequent calls to tab count cross the max tab count
+// threshhold (increasing), the title is blank but the a11y value is set to the
+// second value.
+//
+// Doesn't do anything when run on an iPad.
+TEST_F(ToolbarControllerTest, TestTabCountBecomesEasterEgg_iPhoneOnly) {
+ if (IsIPadIdiom())
+ return;
+
+ [toolbarController_ setTabCount:kStackButtonMaxTabCount];
+ EXPECT_NSEQ(kStackButtonMaxTabCountString,
+ [toolbarController_ stackButton].currentTitle);
+
+ [toolbarController_ setTabCount:kStackButtonEasterEggTabCount];
+ EXPECT_NSEQ(kStackButtonEasterEggString,
+ [toolbarController_ stackButton].currentTitle);
+}
+
+// Verify that when subsequent calls to tab count cross the max tab count
+// threshhold (decreasing), title and a11y value are both set to the second
+// value.
+//
+// Doesn't do anything when run on an iPad.
+TEST_F(ToolbarControllerTest, TestTabCountStopsBeingEasterEgg_iPhoneOnly) {
+ if (IsIPadIdiom())
+ return;
+
+ [toolbarController_ setTabCount:kStackButtonEasterEggTabCount];
+ EXPECT_NSEQ(kStackButtonEasterEggString,
+ [toolbarController_ stackButton].currentTitle);
+
+ [toolbarController_ setTabCount:kStackButtonMaxTabCount];
+ EXPECT_NSEQ(kStackButtonMaxTabCountString,
+ [toolbarController_ stackButton].currentTitle);
+}
+
+} // namespace
« 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