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

Unified Diff: chrome/browser/extensions/api/file_handlers/directory_util_unittest.cc

Issue 2685883008: Revert of Move file_handlers API from //chrome to //extensions (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/file_handlers/directory_util_unittest.cc
diff --git a/chrome/browser/extensions/api/file_handlers/directory_util_unittest.cc b/chrome/browser/extensions/api/file_handlers/directory_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c9549c11399c67f67693b2d7fea3dbfcbbabd2e6
--- /dev/null
+++ b/chrome/browser/extensions/api/file_handlers/directory_util_unittest.cc
@@ -0,0 +1,69 @@
+// Copyright 2016 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 "chrome/browser/extensions/api/file_handlers/directory_util.h"
+
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/run_loop.h"
+#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+namespace app_file_handler_util {
+namespace {
+
+const char kRandomPath[] = "/random/path";
+
+void OnCollectForEntriesPath(
+ std::set<base::FilePath>* output,
+ std::unique_ptr<std::set<base::FilePath>> path_directory_set) {
+ *output = *path_directory_set;
+}
+
+} // namespace
+
+class IsDirectoryUtilTest : public testing::Test {
+ protected:
+ IsDirectoryUtilTest() {}
+ ~IsDirectoryUtilTest() override {}
+
+ void SetUp() override {
+ EXPECT_TRUE(
+ base::CreateNewTempDirectory(base::FilePath::StringType(), &dir_path_));
+ EXPECT_TRUE(base::CreateTemporaryFile(&file_path_));
+ }
+
+ content::TestBrowserThreadBundle thread_bundle_;
+ TestingProfile profile_;
+ base::FilePath dir_path_;
+ base::FilePath file_path_;
+};
+
+TEST_F(IsDirectoryUtilTest, CollectForEntriesPaths) {
+ std::vector<base::FilePath> paths;
+ paths.push_back(dir_path_);
+ paths.push_back(file_path_);
+ paths.push_back(base::FilePath::FromUTF8Unsafe(kRandomPath));
+
+ IsDirectoryCollector collector(&profile_);
+ std::set<base::FilePath> result;
+ collector.CollectForEntriesPaths(
+ paths, base::Bind(&OnCollectForEntriesPath, &result));
+ content::RunAllBlockingPoolTasksUntilIdle();
+
+ ASSERT_EQ(1u, result.size());
+ EXPECT_GT(result.count(dir_path_), 0u);
+}
+
+} // namespace app_file_handler_util
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/file_handlers/directory_util.cc ('k') | chrome/browser/extensions/api/file_handlers/mime_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698