| Index: components/os_crypt/key_storage_util_linux_unittest.cc
|
| diff --git a/components/os_crypt/key_storage_util_linux_unittest.cc b/components/os_crypt/key_storage_util_linux_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b6ccf5d005b3a45f3a3a89fd88418a40fb9de532
|
| --- /dev/null
|
| +++ b/components/os_crypt/key_storage_util_linux_unittest.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2017 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 "components/os_crypt/key_storage_util_linux.h"
|
| +#include "base/files/file_path.h"
|
| +#include "base/files/file_util.h"
|
| +#include "base/logging.h"
|
| +#include "base/macros.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace {
|
| +
|
| +class KeyStorageUtilLinuxTest : public testing::Test {
|
| + public:
|
| + KeyStorageUtilLinuxTest() = default;
|
| + ~KeyStorageUtilLinuxTest() override = default;
|
| +
|
| + void SetUp() override {
|
| + ASSERT_TRUE(base::CreateNewTempDirectory("", &fake_user_data_dir_));
|
| + }
|
| +
|
| + void TearDown() override {
|
| + ASSERT_TRUE(base::DeleteFile(fake_user_data_dir_, true));
|
| + }
|
| +
|
| + protected:
|
| + base::FilePath fake_user_data_dir_;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(KeyStorageUtilLinuxTest);
|
| +};
|
| +
|
| +TEST_F(KeyStorageUtilLinuxTest, FirstTimeDefaultsToTrue) {
|
| + EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_));
|
| +}
|
| +
|
| +TEST_F(KeyStorageUtilLinuxTest, SetToTrue) {
|
| + EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, true));
|
| + EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_));
|
| +}
|
| +
|
| +TEST_F(KeyStorageUtilLinuxTest, SetToFalse) {
|
| + EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false));
|
| + EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_));
|
| +}
|
| +
|
| +TEST_F(KeyStorageUtilLinuxTest, MultipleWrites) {
|
| + EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false));
|
| + EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_));
|
| +
|
| + EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, true));
|
| + EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_));
|
| +
|
| + EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false));
|
| + EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_));
|
| +}
|
| +
|
| +} // namespace
|
|
|