Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Side by Side Diff: extensions/browser/api/file_handlers/directory_util_unittest.cc

Issue 2685453002: Move file_handlers API from //chrome to //extensions (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "extensions/browser/api/extensions_api_client.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace extensions { 22 namespace extensions {
22 namespace app_file_handler_util { 23 namespace app_file_handler_util {
23 namespace { 24 namespace {
24 25
25 const char kRandomPath[] = "/random/path"; 26 const char kRandomPath[] = "/random/path";
26 27
27 void OnCollectForEntriesPath( 28 void OnCollectForEntriesPath(
28 std::set<base::FilePath>* output, 29 std::set<base::FilePath>* output,
29 std::unique_ptr<std::set<base::FilePath>> path_directory_set) { 30 std::unique_ptr<std::set<base::FilePath>> path_directory_set) {
30 *output = *path_directory_set; 31 *output = *path_directory_set;
31 } 32 }
32 33
33 } // namespace 34 } // namespace
34 35
35 class IsDirectoryUtilTest : public testing::Test { 36 class IsDirectoryUtilTest : public testing::Test {
36 protected: 37 protected:
37 IsDirectoryUtilTest() {} 38 IsDirectoryUtilTest() {}
38 ~IsDirectoryUtilTest() override {} 39 ~IsDirectoryUtilTest() override {}
39 40
40 void SetUp() override { 41 void SetUp() override {
41 EXPECT_TRUE( 42 EXPECT_TRUE(
42 base::CreateNewTempDirectory(base::FilePath::StringType(), &dir_path_)); 43 base::CreateNewTempDirectory(base::FilePath::StringType(), &dir_path_));
43 EXPECT_TRUE(base::CreateTemporaryFile(&file_path_)); 44 EXPECT_TRUE(base::CreateTemporaryFile(&file_path_));
44 } 45 }
45 46
46 content::TestBrowserThreadBundle thread_bundle_; 47 content::TestBrowserThreadBundle thread_bundle_;
47 TestingProfile profile_; 48 ExtensionsAPIClient extensions_api_client_;
49 content::TestBrowserContext context_;
48 base::FilePath dir_path_; 50 base::FilePath dir_path_;
49 base::FilePath file_path_; 51 base::FilePath file_path_;
50 }; 52 };
51 53
52 TEST_F(IsDirectoryUtilTest, CollectForEntriesPaths) { 54 TEST_F(IsDirectoryUtilTest, CollectForEntriesPaths) {
53 std::vector<base::FilePath> paths; 55 std::vector<base::FilePath> paths;
54 paths.push_back(dir_path_); 56 paths.push_back(dir_path_);
55 paths.push_back(file_path_); 57 paths.push_back(file_path_);
56 paths.push_back(base::FilePath::FromUTF8Unsafe(kRandomPath)); 58 paths.push_back(base::FilePath::FromUTF8Unsafe(kRandomPath));
57 59
58 IsDirectoryCollector collector(&profile_); 60 IsDirectoryCollector collector(&context_);
59 std::set<base::FilePath> result; 61 std::set<base::FilePath> result;
60 collector.CollectForEntriesPaths( 62 collector.CollectForEntriesPaths(
61 paths, base::Bind(&OnCollectForEntriesPath, &result)); 63 paths, base::Bind(&OnCollectForEntriesPath, &result));
62 content::RunAllBlockingPoolTasksUntilIdle(); 64 content::RunAllBlockingPoolTasksUntilIdle();
63 65
64 ASSERT_EQ(1u, result.size()); 66 ASSERT_EQ(1u, result.size());
65 EXPECT_GT(result.count(dir_path_), 0u); 67 EXPECT_GT(result.count(dir_path_), 0u);
66 } 68 }
67 69
68 } // namespace app_file_handler_util 70 } // namespace app_file_handler_util
69 } // namespace extensions 71 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/file_handlers/directory_util.cc ('k') | extensions/browser/api/file_handlers/mime_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698