diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Android.mk | 1 | ||||
-rw-r--r-- | tests/unit/commands_test.cpp | 37 | ||||
-rw-r--r-- | tests/unit/screen_ui_test.cpp | 12 |
3 files changed, 48 insertions, 2 deletions
diff --git a/tests/Android.mk b/tests/Android.mk index efe46b8ee..cee94dc99 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -37,6 +37,7 @@ LOCAL_STATIC_LIBRARIES := \ LOCAL_SRC_FILES := \ unit/asn1_decoder_test.cpp \ + unit/commands_test.cpp \ unit/dirutil_test.cpp \ unit/locale_test.cpp \ unit/rangeset_test.cpp \ diff --git a/tests/unit/commands_test.cpp b/tests/unit/commands_test.cpp new file mode 100644 index 000000000..18aa471ab --- /dev/null +++ b/tests/unit/commands_test.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <string> + +#include <gtest/gtest.h> + +#include "private/commands.h" + +TEST(CommandsTest, ParseType) { + ASSERT_EQ(Command::Type::ZERO, Command::ParseType("zero")); + ASSERT_EQ(Command::Type::NEW, Command::ParseType("new")); + ASSERT_EQ(Command::Type::ERASE, Command::ParseType("erase")); + ASSERT_EQ(Command::Type::MOVE, Command::ParseType("move")); + ASSERT_EQ(Command::Type::BSDIFF, Command::ParseType("bsdiff")); + ASSERT_EQ(Command::Type::IMGDIFF, Command::ParseType("imgdiff")); + ASSERT_EQ(Command::Type::STASH, Command::ParseType("stash")); + ASSERT_EQ(Command::Type::FREE, Command::ParseType("free")); +} + +TEST(CommandsTest, ParseType_InvalidCommand) { + ASSERT_EQ(Command::Type::LAST, Command::ParseType("foo")); + ASSERT_EQ(Command::Type::LAST, Command::ParseType("bar")); +} diff --git a/tests/unit/screen_ui_test.cpp b/tests/unit/screen_ui_test.cpp index 269222faa..25623074c 100644 --- a/tests/unit/screen_ui_test.cpp +++ b/tests/unit/screen_ui_test.cpp @@ -279,8 +279,6 @@ class ScreenRecoveryUITest : public ::testing::Test { testdata_dir_ = from_testdata_base(""); Paths::Get().set_resource_dir(testdata_dir_); res_set_resource_dir(testdata_dir_); - - ASSERT_TRUE(ui_->Init(kTestLocale)); } std::unique_ptr<TestableScreenRecoveryUI> ui_; @@ -288,6 +286,7 @@ class ScreenRecoveryUITest : public ::testing::Test { }; TEST_F(ScreenRecoveryUITest, Init) { + ASSERT_TRUE(ui_->Init(kTestLocale)); ASSERT_EQ(kTestLocale, ui_->GetLocale()); ASSERT_FALSE(ui_->GetRtlLocale()); ASSERT_FALSE(ui_->IsTextVisible()); @@ -295,6 +294,7 @@ TEST_F(ScreenRecoveryUITest, Init) { } TEST_F(ScreenRecoveryUITest, ShowText) { + ASSERT_TRUE(ui_->Init(kTestLocale)); ASSERT_FALSE(ui_->IsTextVisible()); ui_->ShowText(true); ASSERT_TRUE(ui_->IsTextVisible()); @@ -308,12 +308,15 @@ TEST_F(ScreenRecoveryUITest, ShowText) { TEST_F(ScreenRecoveryUITest, RtlLocale) { ASSERT_TRUE(ui_->Init(kTestRtlLocale)); ASSERT_TRUE(ui_->GetRtlLocale()); +} +TEST_F(ScreenRecoveryUITest, RtlLocaleWithSuffix) { ASSERT_TRUE(ui_->Init(kTestRtlLocaleWithSuffix)); ASSERT_TRUE(ui_->GetRtlLocale()); } TEST_F(ScreenRecoveryUITest, ShowMenu) { + ASSERT_TRUE(ui_->Init(kTestLocale)); ui_->SetKeyBuffer({ KeyCode::UP, KeyCode::DOWN, @@ -339,6 +342,7 @@ TEST_F(ScreenRecoveryUITest, ShowMenu) { } TEST_F(ScreenRecoveryUITest, ShowMenu_NotMenuOnly) { + ASSERT_TRUE(ui_->Init(kTestLocale)); ui_->SetKeyBuffer({ KeyCode::MAGIC, }); @@ -349,6 +353,7 @@ TEST_F(ScreenRecoveryUITest, ShowMenu_NotMenuOnly) { } TEST_F(ScreenRecoveryUITest, ShowMenu_TimedOut) { + ASSERT_TRUE(ui_->Init(kTestLocale)); ui_->SetKeyBuffer({ KeyCode::TIMEOUT, }); @@ -356,6 +361,7 @@ TEST_F(ScreenRecoveryUITest, ShowMenu_TimedOut) { } TEST_F(ScreenRecoveryUITest, ShowMenu_TimedOut_TextWasEverVisible) { + ASSERT_TRUE(ui_->Init(kTestLocale)); ui_->ShowText(true); ui_->ShowText(false); ASSERT_TRUE(ui_->WasTextEverVisible()); @@ -371,6 +377,7 @@ TEST_F(ScreenRecoveryUITest, ShowMenu_TimedOut_TextWasEverVisible) { } TEST_F(ScreenRecoveryUITest, LoadAnimation) { + ASSERT_TRUE(ui_->Init(kTestLocale)); // Make a few copies of loop00000.png from testdata. std::string image_data; ASSERT_TRUE(android::base::ReadFileToString(testdata_dir_ + "/loop00000.png", &image_data)); @@ -398,6 +405,7 @@ TEST_F(ScreenRecoveryUITest, LoadAnimation) { } TEST_F(ScreenRecoveryUITest, LoadAnimation_MissingAnimation) { + ASSERT_TRUE(ui_->Init(kTestLocale)); TemporaryDir resource_dir; Paths::Get().set_resource_dir(resource_dir.path); ASSERT_EXIT(ui_->RunLoadAnimation(), ::testing::KilledBySignal(SIGABRT), ""); |