OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/extensions/api/file_handlers/directory_util.h" | 5 #include "extensions/browser/api/file_handlers/directory_util.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "chrome/test/base/testing_profile.h" | |
16 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/test/test_browser_context.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 namespace app_file_handler_util { | 22 namespace app_file_handler_util { |
23 namespace { | 23 namespace { |
24 | 24 |
25 const char kRandomPath[] = "/random/path"; | 25 const char kRandomPath[] = "/random/path"; |
26 | 26 |
(...skipping 10 matching lines...) Expand all Loading... |
37 IsDirectoryUtilTest() {} | 37 IsDirectoryUtilTest() {} |
38 ~IsDirectoryUtilTest() override {} | 38 ~IsDirectoryUtilTest() override {} |
39 | 39 |
40 void SetUp() override { | 40 void SetUp() override { |
41 EXPECT_TRUE( | 41 EXPECT_TRUE( |
42 base::CreateNewTempDirectory(base::FilePath::StringType(), &dir_path_)); | 42 base::CreateNewTempDirectory(base::FilePath::StringType(), &dir_path_)); |
43 EXPECT_TRUE(base::CreateTemporaryFile(&file_path_)); | 43 EXPECT_TRUE(base::CreateTemporaryFile(&file_path_)); |
44 } | 44 } |
45 | 45 |
46 content::TestBrowserThreadBundle thread_bundle_; | 46 content::TestBrowserThreadBundle thread_bundle_; |
47 TestingProfile profile_; | 47 content::TestBrowserContext context_; |
48 base::FilePath dir_path_; | 48 base::FilePath dir_path_; |
49 base::FilePath file_path_; | 49 base::FilePath file_path_; |
50 }; | 50 }; |
51 | 51 |
52 TEST_F(IsDirectoryUtilTest, CollectForEntriesPaths) { | 52 TEST_F(IsDirectoryUtilTest, CollectForEntriesPaths) { |
53 std::vector<base::FilePath> paths; | 53 std::vector<base::FilePath> paths; |
54 paths.push_back(dir_path_); | 54 paths.push_back(dir_path_); |
55 paths.push_back(file_path_); | 55 paths.push_back(file_path_); |
56 paths.push_back(base::FilePath::FromUTF8Unsafe(kRandomPath)); | 56 paths.push_back(base::FilePath::FromUTF8Unsafe(kRandomPath)); |
57 | 57 |
58 IsDirectoryCollector collector(&profile_); | 58 IsDirectoryCollector collector(&context_); |
59 std::set<base::FilePath> result; | 59 std::set<base::FilePath> result; |
60 collector.CollectForEntriesPaths( | 60 collector.CollectForEntriesPaths( |
61 paths, base::Bind(&OnCollectForEntriesPath, &result)); | 61 paths, base::Bind(&OnCollectForEntriesPath, &result)); |
62 content::RunAllBlockingPoolTasksUntilIdle(); | 62 content::RunAllBlockingPoolTasksUntilIdle(); |
63 | 63 |
64 ASSERT_EQ(1u, result.size()); | 64 ASSERT_EQ(1u, result.size()); |
65 EXPECT_GT(result.count(dir_path_), 0u); | 65 EXPECT_GT(result.count(dir_path_), 0u); |
66 } | 66 } |
67 | 67 |
68 } // namespace app_file_handler_util | 68 } // namespace app_file_handler_util |
69 } // namespace extensions | 69 } // namespace extensions |
OLD | NEW |