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

Side by Side Diff: chrome/browser/chromeos/fileapi/external_file_url_util_unittest.cc

Issue 580023003: Rename the drive: scheme with the externalfile: scheme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
(Empty)
1 // Copyright 2014 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
5 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/drive/file_system_util.h"
9 #include "chrome/test/base/testing_browser_process.h"
10 #include "chrome/test/base/testing_profile_manager.h"
11 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace chromeos {
15
16 namespace {
17
18 // Sets up ProfileManager for testing and marks the current thread as UI by
19 // TestBrowserThreadBundle. We need the thread since Profile objects must be
20 // touched from UI and hence has CHECK/DCHECKs for it.
21 class ProfileRelatedFileSystemUtilTest : public testing::Test {
22 protected:
23 ProfileRelatedFileSystemUtilTest()
24 : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {}
25
26 virtual void SetUp() OVERRIDE {
27 ASSERT_TRUE(testing_profile_manager_.SetUp());
28 }
29
30 TestingProfileManager& testing_profile_manager() {
31 return testing_profile_manager_;
32 }
33
34 private:
35 content::TestBrowserThreadBundle thread_bundle_;
36 TestingProfileManager testing_profile_manager_;
37 };
38
39 } // namespace
40
41 TEST(FileSystemUtilTest, FilePathToExternalFileURL) {
42 base::FilePath path;
43
44 // Path with alphabets and numbers.
45 path = drive::util::GetDriveMyDriveRootPath().AppendASCII("foo/bar012.txt");
46 EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
47
48 // Path with symbols.
49 path = drive::util::GetDriveMyDriveRootPath().AppendASCII(
50 " !\"#$%&'()*+,-.:;<=>?@[\\]^_`{|}~");
51 EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
52
53 // Path with '%'.
54 path = drive::util::GetDriveMyDriveRootPath().AppendASCII("%19%20%21.txt");
55 EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
56
57 // Path with multi byte characters.
58 base::string16 utf16_string;
59 utf16_string.push_back(0x307b); // HIRAGANA_LETTER_HO
60 utf16_string.push_back(0x3052); // HIRAGANA_LETTER_GE
61 path = drive::util::GetDriveMyDriveRootPath().Append(
62 base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(utf16_string) + ".txt"));
63 EXPECT_EQ(path, ExternalFileURLToFilePath(FilePathToExternalFileURL(path)));
64 }
65
66 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698