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

Unified Diff: ui/base/template_expressions_unittest.cc

Issue 2681623002: [i18n] $i18nPolymer to backslash escape (Closed)
Patch Set: moo Created 3 years, 10 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
« no previous file with comments | « ui/base/template_expressions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/template_expressions_unittest.cc
diff --git a/ui/base/template_expressions_unittest.cc b/ui/base/template_expressions_unittest.cc
index c219d0c7db95cc82ef06593a6fc78e86c59b7cc3..984817c2444109bd075045a7219d2fa07fc66d1f 100644
--- a/ui/base/template_expressions_unittest.cc
+++ b/ui/base/template_expressions_unittest.cc
@@ -54,4 +54,35 @@ TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsRaw) {
ReplaceTemplateExpressions("$i18nRaw{rawSample}", substitutions));
}
+TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsPolymerQuoting) {
+ static TemplateReplacements substitutions;
+ substitutions["singleSample"] = "don't do it";
+ substitutions["doubleSample"] = "\"moo\" said the cow";
+ // This resolves |Call('don\'t do it')| to Polymer, which is presented as
+ // |don't do it| to the user.
+ EXPECT_EQ("<div>[[Call('don\\'t do it')]]",
+ ReplaceTemplateExpressions(
+ "<div>[[Call('$i18nPolymer{singleSample}')]]", substitutions));
+ // This resolves |Call('\"moo\" said the cow')| to Polymer, which is
+ // presented as |"moo" said the cow| to the user.
+ EXPECT_EQ("<div>[[Call('\\\"moo\\\" said the cow')]]",
+ ReplaceTemplateExpressions(
+ "<div>[[Call('$i18nPolymer{doubleSample}')]]", substitutions));
+}
+
+TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsPolymerMixed) {
+ static TemplateReplacements substitutions;
+ substitutions["punctuationSample"] = "a\"b'c<d>e&f";
+ substitutions["htmlSample"] = "<div>hello</div>";
+ EXPECT_EQ("a\\\"b\\'c<d>e&f",
+ ReplaceTemplateExpressions("$i18nPolymer{punctuationSample}",
+ substitutions));
+ EXPECT_EQ("<div>hello</div>", ReplaceTemplateExpressions(
+ "$i18nPolymer{htmlSample}", substitutions));
+ EXPECT_EQ("multiple: <div>hello</div>, a\\\"b\\'c<d>e&f.",
+ ReplaceTemplateExpressions("multiple: $i18nPolymer{htmlSample}, "
+ "$i18nPolymer{punctuationSample}.",
+ substitutions));
+}
+
} // namespace ui
« no previous file with comments | « ui/base/template_expressions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698