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

Unified Diff: base/i18n/rtl_unittest.cc

Issue 1162603004: Restore locales after tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make restores scoped Created 5 years, 4 months 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: base/i18n/rtl_unittest.cc
diff --git a/base/i18n/rtl_unittest.cc b/base/i18n/rtl_unittest.cc
index ddaff1e4372026b44cff21ac00906fcb8fc19db3..a35539fa22575c85d4ea1b3ea4e2871b5c0cbc1d 100644
--- a/base/i18n/rtl_unittest.cc
+++ b/base/i18n/rtl_unittest.cc
@@ -19,6 +19,21 @@ namespace i18n {
namespace {
+class ScopedSetICUDefaultLocale {
+ std::string default_locale;
+
+ public:
+ ScopedSetICUDefaultLocale(std::string locale);
+ ~ScopedSetICUDefaultLocale();
+};
+
+ScopedSetICUDefaultLocale::ScopedSetICUDefaultLocale(std::string locale)
+ : default_locale(locale) {}
+
+ScopedSetICUDefaultLocale::~ScopedSetICUDefaultLocale() {
+ i18n::SetICUDefaultLocale(default_locale.data());
+}
+
// A test utility function to set the application default text direction.
void SetRTL(bool rtl) {
// Override the current locale/direction.
@@ -305,6 +320,7 @@ TEST_F(RTLTest, WrapString) {
const bool was_rtl = IsRTL();
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault());
for (size_t i = 0; i < 2; ++i) {
// Toggle the application default text direction (to try each direction).
SetRTL(!IsRTL());
@@ -352,6 +368,7 @@ TEST_F(RTLTest, GetDisplayStringInLTRDirectionality) {
const bool was_rtl = IsRTL();
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault());
for (size_t i = 0; i < 2; ++i) {
// Toggle the application default text direction (to try each direction).
SetRTL(!IsRTL());
@@ -438,6 +455,7 @@ TEST_F(RTLTest, UnadjustStringForLocaleDirection) {
const bool was_rtl = IsRTL();
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault());
for (size_t i = 0; i < 2; ++i) {
// Toggle the application default text direction (to try each direction).
SetRTL(!IsRTL());

Powered by Google App Engine
This is Rietveld 408576698