test_data_directory.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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
  3. // found in the LICENSE file.
  4. #include "net/test/test_data_directory.h"
  5. #include "base/base_paths.h"
  6. #include "base/path_service.h"
  7. #include "base/threading/thread_restrictions.h"
  8. namespace net {
  9. namespace {
  10. // Net directory, relative to source root.
  11. const base::FilePath::CharType kNetRelativePath[] = FILE_PATH_LITERAL("net");
  12. // Net data directory, relative to net directory.
  13. const base::FilePath::CharType kNetDataRelativePath[] =
  14. FILE_PATH_LITERAL("data");
  15. // Test certificates directory, relative to kNetDataRelativePath.
  16. const base::FilePath::CharType kCertificateDataSubPath[] =
  17. FILE_PATH_LITERAL("ssl/certificates");
  18. } // namespace
  19. base::FilePath GetTestNetDirectory() {
  20. base::FilePath src_root;
  21. {
  22. base::ScopedAllowBlockingForTesting allow_blocking;
  23. base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root);
  24. }
  25. return src_root.Append(kNetRelativePath);
  26. }
  27. base::FilePath GetTestNetDataDirectory() {
  28. return GetTestNetDirectory().Append(kNetDataRelativePath);
  29. }
  30. base::FilePath GetTestCertsDirectory() {
  31. return GetTestNetDataDirectory().Append(kCertificateDataSubPath);
  32. }
  33. base::FilePath GetTestClientCertsDirectory() {
  34. return base::FilePath(kNetDataRelativePath).Append(kCertificateDataSubPath);
  35. }
  36. base::FilePath GetWebSocketTestDataDirectory() {
  37. base::FilePath data_dir(FILE_PATH_LITERAL("net/data/websocket"));
  38. return data_dir;
  39. }
  40. } // namespace net