AAPT2: Rename to match new style
Use Google3 naming style to match new
projects' and open source google projects' style.
Preferred to do this in a massive CL so as to avoid
style inconsistencies that plague legacy code bases.
This is a relatively NEW code base, may as well keep
it up to date.
Test: name/style refactor - existing tests pass
Change-Id: Ie80ecb78d46ec53efdfca2336bb57d96cbb7fb87
diff --git a/tools/aapt2/compile/Pseudolocalizer_test.cpp b/tools/aapt2/compile/Pseudolocalizer_test.cpp
index a152ed6..92eb3b5 100644
--- a/tools/aapt2/compile/Pseudolocalizer_test.cpp
+++ b/tools/aapt2/compile/Pseudolocalizer_test.cpp
@@ -15,33 +15,32 @@
*/
#include "compile/Pseudolocalizer.h"
-#include "util/Util.h"
-#include <androidfw/ResourceTypes.h>
-#include <gtest/gtest.h>
+#include "test/Test.h"
+#include "util/Util.h"
namespace aapt {
// In this context, 'Axis' represents a particular field in the configuration,
// such as language or density.
-static ::testing::AssertionResult simpleHelper(const char* input,
+static ::testing::AssertionResult SimpleHelper(const char* input,
const char* expected,
Pseudolocalizer::Method method) {
Pseudolocalizer pseudo(method);
- std::string result = pseudo.start() + pseudo.text(input) + pseudo.end();
+ std::string result = pseudo.Start() + pseudo.Text(input) + pseudo.End();
if (result != expected) {
return ::testing::AssertionFailure() << expected << " != " << result;
}
return ::testing::AssertionSuccess();
}
-static ::testing::AssertionResult compoundHelper(
+static ::testing::AssertionResult CompoundHelper(
const char* in1, const char* in2, const char* in3, const char* expected,
Pseudolocalizer::Method method) {
Pseudolocalizer pseudo(method);
- std::string result = pseudo.start() + pseudo.text(in1) + pseudo.text(in2) +
- pseudo.text(in3) + pseudo.end();
+ std::string result = pseudo.Start() + pseudo.Text(in1) + pseudo.Text(in2) +
+ pseudo.Text(in3) + pseudo.End();
if (result != expected) {
return ::testing::AssertionFailure() << expected << " != " << result;
}
@@ -49,49 +48,49 @@
}
TEST(PseudolocalizerTest, NoPseudolocalization) {
- EXPECT_TRUE(simpleHelper("", "", Pseudolocalizer::Method::kNone));
- EXPECT_TRUE(simpleHelper("Hello, world", "Hello, world",
+ EXPECT_TRUE(SimpleHelper("", "", Pseudolocalizer::Method::kNone));
+ EXPECT_TRUE(SimpleHelper("Hello, world", "Hello, world",
Pseudolocalizer::Method::kNone));
- EXPECT_TRUE(compoundHelper("Hello,", " world", "", "Hello, world",
+ EXPECT_TRUE(CompoundHelper("Hello,", " world", "", "Hello, world",
Pseudolocalizer::Method::kNone));
}
TEST(PseudolocalizerTest, PlaintextAccent) {
- EXPECT_TRUE(simpleHelper("", "[]", Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(simpleHelper("Hello, world", "[Ĥéļļö, ŵöŕļð one two]",
+ EXPECT_TRUE(SimpleHelper("", "[]", Pseudolocalizer::Method::kAccent));
+ EXPECT_TRUE(SimpleHelper("Hello, world", "[Ĥéļļö, ŵöŕļð one two]",
Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(simpleHelper("Hello, %1d", "[Ĥéļļö, »%1d« one two]",
+ EXPECT_TRUE(SimpleHelper("Hello, %1d", "[Ĥéļļö, »%1d« one two]",
Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(simpleHelper("Battery %1d%%", "[βåţţéŕý »%1d«%% one two]",
+ EXPECT_TRUE(SimpleHelper("Battery %1d%%", "[βåţţéŕý »%1d«%% one two]",
Pseudolocalizer::Method::kAccent));
EXPECT_TRUE(
- simpleHelper("^1 %", "[^1 % one]", Pseudolocalizer::Method::kAccent));
+ SimpleHelper("^1 %", "[^1 % one]", Pseudolocalizer::Method::kAccent));
EXPECT_TRUE(
- compoundHelper("", "", "", "[]", Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(compoundHelper("Hello,", " world", "", "[Ĥéļļö, ŵöŕļð one two]",
+ CompoundHelper("", "", "", "[]", Pseudolocalizer::Method::kAccent));
+ EXPECT_TRUE(CompoundHelper("Hello,", " world", "", "[Ĥéļļö, ŵöŕļð one two]",
Pseudolocalizer::Method::kAccent));
}
TEST(PseudolocalizerTest, PlaintextBidi) {
- EXPECT_TRUE(simpleHelper("", "", Pseudolocalizer::Method::kBidi));
- EXPECT_TRUE(simpleHelper(
+ EXPECT_TRUE(SimpleHelper("", "", Pseudolocalizer::Method::kBidi));
+ EXPECT_TRUE(SimpleHelper(
"word", "\xe2\x80\x8f\xE2\x80\xaeword\xE2\x80\xac\xe2\x80\x8f",
Pseudolocalizer::Method::kBidi));
- EXPECT_TRUE(simpleHelper(
+ EXPECT_TRUE(SimpleHelper(
" word ", " \xe2\x80\x8f\xE2\x80\xaeword\xE2\x80\xac\xe2\x80\x8f ",
Pseudolocalizer::Method::kBidi));
- EXPECT_TRUE(simpleHelper(
+ EXPECT_TRUE(SimpleHelper(
" word ", " \xe2\x80\x8f\xE2\x80\xaeword\xE2\x80\xac\xe2\x80\x8f ",
Pseudolocalizer::Method::kBidi));
EXPECT_TRUE(
- simpleHelper("hello\n world\n",
+ SimpleHelper("hello\n world\n",
"\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\n"
" \xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\n",
Pseudolocalizer::Method::kBidi));
- EXPECT_TRUE(compoundHelper(
+ EXPECT_TRUE(CompoundHelper(
"hello", "\n ", " world\n",
"\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\n"
" \xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\n",
@@ -100,33 +99,33 @@
TEST(PseudolocalizerTest, SimpleICU) {
// Single-fragment messages
- EXPECT_TRUE(simpleHelper("{placeholder}", "[»{placeholder}«]",
+ EXPECT_TRUE(SimpleHelper("{placeholder}", "[»{placeholder}«]",
Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(simpleHelper("{USER} is offline", "[»{USER}« îš öƒƒļîñé one two]",
+ EXPECT_TRUE(SimpleHelper("{USER} is offline", "[»{USER}« îš öƒƒļîñé one two]",
Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(simpleHelper("Copy from {path1} to {path2}",
+ EXPECT_TRUE(SimpleHelper("Copy from {path1} to {path2}",
"[Çöþý ƒŕöḿ »{path1}« ţö »{path2}« one two three]",
Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(simpleHelper("Today is {1,date} {1,time}",
+ EXPECT_TRUE(SimpleHelper("Today is {1,date} {1,time}",
"[Ţöðåý îš »{1,date}« »{1,time}« one two]",
Pseudolocalizer::Method::kAccent));
// Multi-fragment messages
- EXPECT_TRUE(compoundHelper("{USER}", " ", "is offline",
+ EXPECT_TRUE(CompoundHelper("{USER}", " ", "is offline",
"[»{USER}« îš öƒƒļîñé one two]",
Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(compoundHelper("Copy from ", "{path1}", " to {path2}",
+ EXPECT_TRUE(CompoundHelper("Copy from ", "{path1}", " to {path2}",
"[Çöþý ƒŕöḿ »{path1}« ţö »{path2}« one two three]",
Pseudolocalizer::Method::kAccent));
}
TEST(PseudolocalizerTest, ICUBidi) {
// Single-fragment messages
- EXPECT_TRUE(simpleHelper(
+ EXPECT_TRUE(SimpleHelper(
"{placeholder}",
"\xe2\x80\x8f\xE2\x80\xae{placeholder}\xE2\x80\xac\xe2\x80\x8f",
Pseudolocalizer::Method::kBidi));
- EXPECT_TRUE(simpleHelper(
+ EXPECT_TRUE(SimpleHelper(
"{COUNT, plural, one {one} other {other}}",
"{COUNT, plural, "
"one {\xe2\x80\x8f\xE2\x80\xaeone\xE2\x80\xac\xe2\x80\x8f} "
@@ -136,30 +135,30 @@
TEST(PseudolocalizerTest, Escaping) {
// Single-fragment messages
- EXPECT_TRUE(simpleHelper("'{USER'} is offline",
+ EXPECT_TRUE(SimpleHelper("'{USER'} is offline",
"['{ÛŠÉŔ'} îš öƒƒļîñé one two three]",
Pseudolocalizer::Method::kAccent));
// Multi-fragment messages
- EXPECT_TRUE(compoundHelper("'{USER}", " ", "''is offline",
+ EXPECT_TRUE(CompoundHelper("'{USER}", " ", "''is offline",
"['{ÛŠÉŔ} ''îš öƒƒļîñé one two three]",
Pseudolocalizer::Method::kAccent));
}
TEST(PseudolocalizerTest, PluralsAndSelects) {
- EXPECT_TRUE(simpleHelper(
+ EXPECT_TRUE(SimpleHelper(
"{COUNT, plural, one {Delete a file} other {Delete {COUNT} files}}",
"[{COUNT, plural, one {Ðéļéţé å ƒîļé one two} "
"other {Ðéļéţé »{COUNT}« ƒîļéš one two}}]",
Pseudolocalizer::Method::kAccent));
EXPECT_TRUE(
- simpleHelper("Distance is {COUNT, plural, one {# mile} other {# miles}}",
+ SimpleHelper("Distance is {COUNT, plural, one {# mile} other {# miles}}",
"[Ðîšţåñçé îš {COUNT, plural, one {# ḿîļé one two} "
"other {# ḿîļéš one two}}]",
Pseudolocalizer::Method::kAccent));
- EXPECT_TRUE(simpleHelper(
+ EXPECT_TRUE(SimpleHelper(
"{1, select, female {{1} added you} "
"male {{1} added you} other {{1} added you}}",
"[{1, select, female {»{1}« åððéð ýöû one two} "
@@ -167,7 +166,7 @@
Pseudolocalizer::Method::kAccent));
EXPECT_TRUE(
- compoundHelper("{COUNT, plural, one {Delete a file} "
+ CompoundHelper("{COUNT, plural, one {Delete a file} "
"other {Delete ",
"{COUNT}", " files}}",
"[{COUNT, plural, one {Ðéļéţé å ƒîļé one two} "
@@ -177,7 +176,7 @@
TEST(PseudolocalizerTest, NestedICU) {
EXPECT_TRUE(
- simpleHelper("{person, select, "
+ SimpleHelper("{person, select, "
"female {"
"{num_circles, plural,"
"=0{{person} didn't add you to any of her circles.}"
@@ -222,9 +221,9 @@
TEST(PseudolocalizerTest, RedefineMethod) {
Pseudolocalizer pseudo(Pseudolocalizer::Method::kAccent);
- std::string result = pseudo.text("Hello, ");
- pseudo.setMethod(Pseudolocalizer::Method::kNone);
- result += pseudo.text("world!");
+ std::string result = pseudo.Text("Hello, ");
+ pseudo.SetMethod(Pseudolocalizer::Method::kNone);
+ result += pseudo.Text("world!");
ASSERT_EQ(StringPiece("Ĥéļļö, world!"), result);
}