1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/test/test_data_directory.h" 6 7 #include "base/base_paths.h" 8 #include "base/path_service.h" 9 #include "base/threading/thread_restrictions.h" 10 11 namespace net { 12 13 namespace { 14 15 // Net directory, relative to source root. 16 const base::FilePath::CharType kNetRelativePath[] = FILE_PATH_LITERAL("net"); 17 18 // Net data directory, relative to net directory. 19 const base::FilePath::CharType kNetDataRelativePath[] = 20 FILE_PATH_LITERAL("data"); 21 22 // Test certificates directory, relative to kNetDataRelativePath. 23 const base::FilePath::CharType kCertificateDataSubPath[] = 24 FILE_PATH_LITERAL("ssl/certificates"); 25 26 } // namespace 27 GetTestNetDirectory()28base::FilePath GetTestNetDirectory() { 29 base::FilePath src_root; 30 { 31 base::ScopedAllowBlockingForTesting allow_blocking; 32 base::PathService::Get(base::DIR_SRC_TEST_DATA_ROOT, &src_root); 33 } 34 35 return src_root.Append(kNetRelativePath); 36 } 37 GetTestNetDataDirectory()38base::FilePath GetTestNetDataDirectory() { 39 return GetTestNetDirectory().Append(kNetDataRelativePath); 40 } 41 GetTestCertsDirectory()42base::FilePath GetTestCertsDirectory() { 43 return GetTestNetDataDirectory().Append(kCertificateDataSubPath); 44 } 45 GetTestClientCertsDirectory()46base::FilePath GetTestClientCertsDirectory() { 47 return base::FilePath(kNetDataRelativePath).Append(kCertificateDataSubPath); 48 } 49 GetWebSocketTestDataDirectory()50base::FilePath GetWebSocketTestDataDirectory() { 51 base::FilePath data_dir(FILE_PATH_LITERAL("net/data/websocket")); 52 return data_dir; 53 } 54 55 } // namespace net 56