| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/os_crypt/key_storage_util_linux.h" |
| 6 #include "base/files/file_path.h" |
| 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" |
| 9 #include "base/macros.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 class KeyStorageUtilLinuxTest : public testing::Test { |
| 15 public: |
| 16 KeyStorageUtilLinuxTest() = default; |
| 17 ~KeyStorageUtilLinuxTest() override = default; |
| 18 |
| 19 void SetUp() override { |
| 20 ASSERT_TRUE(base::CreateNewTempDirectory("", &fake_user_data_dir_)); |
| 21 } |
| 22 |
| 23 void TearDown() override { |
| 24 ASSERT_TRUE(base::DeleteFile(fake_user_data_dir_, true)); |
| 25 } |
| 26 |
| 27 protected: |
| 28 base::FilePath fake_user_data_dir_; |
| 29 |
| 30 private: |
| 31 DISALLOW_COPY_AND_ASSIGN(KeyStorageUtilLinuxTest); |
| 32 }; |
| 33 |
| 34 TEST_F(KeyStorageUtilLinuxTest, FirstTimeDefaultsToTrue) { |
| 35 EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_)); |
| 36 } |
| 37 |
| 38 TEST_F(KeyStorageUtilLinuxTest, SetToTrue) { |
| 39 EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, true)); |
| 40 EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_)); |
| 41 } |
| 42 |
| 43 TEST_F(KeyStorageUtilLinuxTest, SetToFalse) { |
| 44 EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false)); |
| 45 EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_)); |
| 46 } |
| 47 |
| 48 TEST_F(KeyStorageUtilLinuxTest, MultipleWrites) { |
| 49 EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false)); |
| 50 EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_)); |
| 51 |
| 52 EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, true)); |
| 53 EXPECT_TRUE(os_crypt::GetBackendUse(fake_user_data_dir_)); |
| 54 |
| 55 EXPECT_TRUE(os_crypt::WriteBackendUse(fake_user_data_dir_, false)); |
| 56 EXPECT_FALSE(os_crypt::GetBackendUse(fake_user_data_dir_)); |
| 57 } |
| 58 |
| 59 } // namespace |
| OLD | NEW |