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

Unified Diff: ui/base/test/scoped_mac_rtl.mm

Issue 2555033003: Add ScopedMacRTL class for Cocoa browser RTL testing (Closed)
Patch Set: Whitespace 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
« ui/base/test/scoped_mac_rtl.h ('K') | « ui/base/test/scoped_mac_rtl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/test/scoped_mac_rtl.mm
diff --git a/ui/base/test/scoped_mac_rtl.mm b/ui/base/test/scoped_mac_rtl.mm
new file mode 100644
index 0000000000000000000000000000000000000000..b779b42e757c330d97e26092da0af135244eec9d
--- /dev/null
+++ b/ui/base/test/scoped_mac_rtl.mm
@@ -0,0 +1,45 @@
+// Copyright 2016 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.
+
+#include "ui/base/test/scoped_mac_rtl.h"
+
+#import <Cocoa/Cocoa.h>
tapted 2016/12/07 23:20:27 nit: NSUserDefaults is in <Foundation/Foundation.h
+
+#include "base/i18n/rtl.h"
+#include "ui/base/cocoa/rtl_feature.h"
+
+namespace {
+
+NSString* const kAppleTextDirectionDefaultsKey = @"AppleTextDirection";
+NSString* const kForceRTLWritingDirectionDefaultsKey =
+ @"NSForceRightToLeftWritingDirection";
+
+} // namespace
+
+namespace ui {
+
+ScopedEnableMacRTLLayout::ScopedEnableMacRTLLayout() {
+ scoped_feature_list_.InitAndEnableFeature(ui::kExperimentalMacRTL);
tapted 2016/12/07 23:20:27 nit: remove `ui::`
+ NSUserDefaults* standard_defaults = [NSUserDefaults standardUserDefaults];
+ original_apple_text_direction_ =
+ [standard_defaults boolForKey:kAppleTextDirectionDefaultsKey];
+ original_rtl_writing_direction_ =
+ [standard_defaults boolForKey:kForceRTLWritingDirectionDefaultsKey];
+ [standard_defaults setBool:YES forKey:kAppleTextDirectionDefaultsKey];
+ [standard_defaults setBool:YES forKey:kForceRTLWritingDirectionDefaultsKey];
+ original_locale_ = base::i18n::GetConfiguredLocale();
+ base::i18n::SetICUDefaultLocale("he");
tapted 2016/12/07 23:20:27 "he" looked really weird the first time I saw it b
+}
+
+ScopedEnableMacRTLLayout::~ScopedEnableMacRTLLayout() {
+ [[NSUserDefaults standardUserDefaults]
+ setBool:original_apple_text_direction_
+ forKey:kAppleTextDirectionDefaultsKey];
+ [[NSUserDefaults standardUserDefaults]
+ setBool:original_rtl_writing_direction_
+ forKey:kForceRTLWritingDirectionDefaultsKey];
+ base::i18n::SetICUDefaultLocale(original_locale_);
+}
+
+} // namespace ui
« ui/base/test/scoped_mac_rtl.h ('K') | « ui/base/test/scoped_mac_rtl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698