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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_controller_unittest.mm

Issue 2555033003: Add ScopedMacRTL class for Cocoa browser RTL testing (Closed)
Patch Set: Review comments 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
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 7
8 #include "base/i18n/rtl.h"
9 #import "base/mac/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
10 #include "base/macros.h" 9 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
12 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/scoped_feature_list.h"
14 #include "chrome/browser/ui/cocoa/l10n_util.h"
15 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h" 12 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h"
16 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 13 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
17 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" 14 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h"
18 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" 15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
19 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 16 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
20 #include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" 17 #include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
18 #include "chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h"
21 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
22 #import "testing/gtest_mac.h" 20 #import "testing/gtest_mac.h"
23 #include "testing/platform_test.h" 21 #include "testing/platform_test.h"
24 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/resources/grit/ui_resources.h" 23 #include "ui/resources/grit/ui_resources.h"
26 24
27 // Implements the target interface for the tab, which gets sent messages when 25 // Implements the target interface for the tab, which gets sent messages when
28 // the tab is clicked on by the user and when its close box is clicked. 26 // the tab is clicked on by the user and when its close box is clicked.
29 @interface TabControllerTestTarget : NSObject<TabControllerTarget> { 27 @interface TabControllerTestTarget : NSObject<TabControllerTarget> {
30 @private 28 @private
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 EXPECT_EQ(RightMargin(originalTabFrame, originalTitleFrame), 575 EXPECT_EQ(RightMargin(originalTabFrame, originalTitleFrame),
578 RightMargin([[controller view] frame], 576 RightMargin([[controller view] frame],
579 [[controller tabView] titleFrame])); 577 [[controller tabView] titleFrame]));
580 } 578 }
581 579
582 TEST_F(TabControllerTest, LayoutAndVisibilityOfSubviews) { 580 TEST_F(TabControllerTest, LayoutAndVisibilityOfSubviews) {
583 CheckLayoutAndVisibilityOfSubviewsForAllStates(false); 581 CheckLayoutAndVisibilityOfSubviewsForAllStates(false);
584 } 582 }
585 583
586 TEST_F(TabControllerTest, LayoutAndVisibilityOfSubviewsRTL) { 584 TEST_F(TabControllerTest, LayoutAndVisibilityOfSubviewsRTL) {
587 std::string old_locale(base::i18n::GetConfiguredLocale()); 585 cocoa_l10n_util::ScopedForceRTLMac scoped_rtl;
588 base::i18n::SetICUDefaultLocale("he");
589 base::test::ScopedFeatureList scoped_feature_list;
590 scoped_feature_list.InitAndEnableFeature(
591 cocoa_l10n_util::kExperimentalMacRTL);
592 // TODO(lgrey): Create ScopedNSUserDefaults or similar to do
593 // this automatically.
594 NSString* const appleTextDirectionDefaultsKey = @"AppleTextDirection";
595 NSString* const forceRTLWritingDirectionDefaultsKey =
596 @"NSForceRightToLeftWritingDirection";
597 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
598 BOOL oldTextDirection = [defaults boolForKey:appleTextDirectionDefaultsKey];
599 BOOL oldRTLWritingDirection =
600 [defaults boolForKey:forceRTLWritingDirectionDefaultsKey];
601 [defaults setBool:YES forKey:appleTextDirectionDefaultsKey];
602 [defaults setBool:YES forKey:forceRTLWritingDirectionDefaultsKey];
603 586
604 CheckLayoutAndVisibilityOfSubviewsForAllStates(true); 587 CheckLayoutAndVisibilityOfSubviewsForAllStates(true);
605
606 base::i18n::SetICUDefaultLocale(old_locale);
607 [defaults setBool:oldTextDirection forKey:appleTextDirectionDefaultsKey];
608 [defaults setBool:oldRTLWritingDirection
609 forKey:forceRTLWritingDirectionDefaultsKey];
610 } 588 }
611 589
612 } // namespace 590 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698