| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/scoped_temp_dir.h" | |
| 8 #include "chrome/browser/extensions/extension_creator_filter.h" | 8 #include "chrome/browser/extensions/extension_creator_filter.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class ExtensionCreatorFilterTest : public PlatformTest { | 14 class ExtensionCreatorFilterTest : public PlatformTest { |
| 15 protected: | 15 protected: |
| 16 virtual void SetUp() { | 16 virtual void SetUp() { |
| 17 PlatformTest::SetUp(); | 17 PlatformTest::SetUp(); |
| 18 | 18 |
| 19 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 19 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 20 test_dir_ = temp_dir_.path(); | 20 test_dir_ = temp_dir_.path(); |
| 21 | 21 |
| 22 filter_ = new extensions::ExtensionCreatorFilter(); | 22 filter_ = new extensions::ExtensionCreatorFilter(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 FilePath CreateEmptyTestFile(const FilePath& file_path) { | 25 FilePath CreateEmptyTestFile(const FilePath& file_path) { |
| 26 FilePath test_file(test_dir_.Append(file_path)); | 26 FilePath test_file(test_dir_.Append(file_path)); |
| 27 FilePath temp_file; | 27 FilePath temp_file; |
| 28 EXPECT_TRUE(file_util::CreateTemporaryFileInDir(test_dir_, &temp_file)); | 28 EXPECT_TRUE(file_util::CreateTemporaryFileInDir(test_dir_, &temp_file)); |
| 29 EXPECT_TRUE(file_util::Move(temp_file, test_file)); | 29 EXPECT_TRUE(file_util::Move(temp_file, test_file)); |
| 30 return test_file; | 30 return test_file; |
| 31 } | 31 } |
| 32 | 32 |
| 33 scoped_refptr<extensions::ExtensionCreatorFilter> filter_; | 33 scoped_refptr<extensions::ExtensionCreatorFilter> filter_; |
| 34 | 34 |
| 35 ScopedTempDir temp_dir_; | 35 base::ScopedTempDir temp_dir_; |
| 36 | 36 |
| 37 FilePath test_dir_; | 37 FilePath test_dir_; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 struct UnaryBooleanTestData { | 40 struct UnaryBooleanTestData { |
| 41 const FilePath::CharType* input; | 41 const FilePath::CharType* input; |
| 42 bool expected; | 42 bool expected; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 TEST_F(ExtensionCreatorFilterTest, NormalCases) { | 45 TEST_F(ExtensionCreatorFilterTest, NormalCases) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 SetFileAttributes(test_file.value().c_str(), FILE_ATTRIBUTE_HIDDEN); | 92 SetFileAttributes(test_file.value().c_str(), FILE_ATTRIBUTE_HIDDEN); |
| 93 } | 93 } |
| 94 bool observed = filter_->ShouldPackageFile(test_file); | 94 bool observed = filter_->ShouldPackageFile(test_file); |
| 95 EXPECT_EQ(cases[i].expected, observed) << | 95 EXPECT_EQ(cases[i].expected, observed) << |
| 96 "i: " << i << ", input: " << test_file.value(); | 96 "i: " << i << ", input: " << test_file.value(); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 } // namespace | 101 } // namespace |
| OLD | NEW |