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

Side by Side Diff: chrome/browser/extensions/extension_file_browser_private_apitest.cc

Issue 8386031: Move chromeos_mount.cc from libcros to Chrome tree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for review comments Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "chrome/browser/chromeos/cros/cros_library.h" 7 #include "chrome/browser/chromeos/dbus/mock_cros_disks_client.h"
8 #include "chrome/browser/chromeos/cros/mock_mount_library.h" 8 #include "chrome/browser/chromeos/dbus/mock_dbus_thread_manager.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "webkit/fileapi/file_system_context.h" 12 #include "webkit/fileapi/file_system_context.h"
13 #include "webkit/fileapi/file_system_mount_point_provider.h" 13 #include "webkit/fileapi/file_system_mount_point_provider.h"
14 #include "webkit/fileapi/file_system_path_manager.h" 14 #include "webkit/fileapi/file_system_path_manager.h"
15 15
16 using ::testing::_; 16 using ::testing::_;
17 using ::testing::ReturnRef; 17 using ::testing::ReturnRef;
18 using ::testing::StrEq; 18 using ::testing::StrEq;
19 19
20 class ExtensionFileBrowserPrivateApiTest : public ExtensionApiTest { 20 class ExtensionFileBrowserPrivateApiTest : public ExtensionApiTest {
21 public: 21 public:
22 ExtensionFileBrowserPrivateApiTest() : test_mount_point_("/tmp") { 22 ExtensionFileBrowserPrivateApiTest() : test_mount_point_("/tmp") {
23 mount_library_mock_.SetupDefaultReplies(); 23 chromeos::MockDBusThreadManager* mock_dbus_thread_manager =
24 24 new chromeos::MockDBusThreadManager;
25 chromeos::CrosLibrary::Get()->GetTestApi()->SetMountLibrary( 25 chromeos::DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager);
26 &mount_library_mock_, 26 cros_disks_client_mock_ =
27 false); // We own the mock library object. 27 mock_dbus_thread_manager->mock_cros_disks_client();
28 cros_disks_client_mock_->SetupDefaultReplies();
28 29
29 CreateVolumeMap(); 30 CreateVolumeMap();
30 } 31 }
31 32
32 virtual ~ExtensionFileBrowserPrivateApiTest() { 33 virtual ~ExtensionFileBrowserPrivateApiTest() {
33 DeleteVolumeMap(); 34 DeleteVolumeMap();
34 chromeos::CrosLibrary::Get()->GetTestApi()->SetMountLibrary(NULL, true);
35 } 35 }
36 36
37 void AddTmpMountPoint() { 37 void AddTmpMountPoint() {
38 fileapi::FileSystemPathManager* path_manager = 38 fileapi::FileSystemPathManager* path_manager =
39 browser()->profile()->GetFileSystemContext()->path_manager(); 39 browser()->profile()->GetFileSystemContext()->path_manager();
40 fileapi::ExternalFileSystemMountPointProvider* provider = 40 fileapi::ExternalFileSystemMountPointProvider* provider =
41 path_manager->external_provider(); 41 path_manager->external_provider();
42 provider->AddMountPoint(test_mount_point_); 42 provider->AddMountPoint(test_mount_point_);
43 } 43 }
44 44
45 private: 45 private:
46 void CreateVolumeMap() { 46 void CreateVolumeMap() {
47 // These have to be sync'd with values in filebrowser_mount extension. 47 // These have to be sync'd with values in filebrowser_mount extension.
48 volumes_.insert( 48 volumes_.insert(
49 std::pair<std::string, chromeos::MountLibrary::Disk*>( 49 std::pair<std::string, chromeos::CrosDisksClient::Disk*>(
50 "device_path1", 50 "device_path1",
51 new chromeos::MountLibrary::Disk("device_path1", 51 new chromeos::CrosDisksClient::Disk("device_path1",
52 "/media/removable/mount_path1", 52 "/media/removable/mount_path1",
53 "system_path1", 53 "system_path1",
54 "file_path1", 54 "file_path1",
55 "device_label1", 55 "device_label1",
56 "drive_label1", 56 "drive_label1",
57 "parent_path1", 57 "parent_path1",
58 "system_path_prefix1", 58 "system_path_prefix1",
59 chromeos::FLASH, 59 chromeos::FLASH,
60 1073741824, 60 1073741824,
61 false, 61 false,
62 false, 62 false,
63 false, 63 false,
64 false, 64 false,
65 false))); 65 false)));
66 volumes_.insert( 66 volumes_.insert(
67 std::pair<std::string, chromeos::MountLibrary::Disk*>( 67 std::pair<std::string, chromeos::CrosDisksClient::Disk*>(
68 "device_path2", 68 "device_path2",
69 new chromeos::MountLibrary::Disk("device_path2", 69 new chromeos::CrosDisksClient::Disk("device_path2",
70 "/media/removable/mount_path2", 70 "/media/removable/mount_path2",
71 "system_path2", 71 "system_path2",
72 "file_path2", 72 "file_path2",
73 "device_label2", 73 "device_label2",
74 "drive_label2", 74 "drive_label2",
75 "parent_path2", 75 "parent_path2",
76 "system_path_prefix2", 76 "system_path_prefix2",
77 chromeos::HDD, 77 chromeos::HDD,
78 47723, 78 47723,
79 true, 79 true,
80 true, 80 true,
81 true, 81 true,
82 true, 82 true,
83 false))); 83 false)));
84 volumes_.insert( 84 volumes_.insert(
85 std::pair<std::string, chromeos::MountLibrary::Disk*>( 85 std::pair<std::string, chromeos::CrosDisksClient::Disk*>(
86 "device_path3", 86 "device_path3",
87 new chromeos::MountLibrary::Disk("device_path3", 87 new chromeos::CrosDisksClient::Disk("device_path3",
88 "/media/removable/mount_path3", 88 "/media/removable/mount_path3",
89 "system_path3", 89 "system_path3",
90 "file_path3", 90 "file_path3",
91 "device_label3", 91 "device_label3",
92 "drive_label3", 92 "drive_label3",
93 "parent_path3", 93 "parent_path3",
94 "system_path_prefix3", 94 "system_path_prefix3",
95 chromeos::OPTICAL, 95 chromeos::OPTICAL,
96 0, 96 0,
97 true, 97 true,
98 false, 98 false,
99 false, 99 false,
100 true, 100 true,
101 false))); 101 false)));
102 } 102 }
103 103
104 void DeleteVolumeMap() { 104 void DeleteVolumeMap() {
105 for (chromeos::MountLibrary::DiskMap::iterator it = volumes_.begin(); 105 for (chromeos::CrosDisksClient::DiskMap::iterator it = volumes_.begin();
106 it != volumes_.end(); 106 it != volumes_.end();
107 ++it) { 107 ++it) {
108 delete it->second; 108 delete it->second;
109 } 109 }
110 volumes_.clear(); 110 volumes_.clear();
111 } 111 }
112 112
113 protected: 113 protected:
114 chromeos::MockMountLibrary mount_library_mock_; 114 chromeos::MockCrosDisksClient* cros_disks_client_mock_;
115 chromeos::MountLibrary::DiskMap volumes_; 115 chromeos::CrosDisksClient::DiskMap volumes_;
116 116
117 private: 117 private:
118 FilePath test_mount_point_; 118 FilePath test_mount_point_;
119 }; 119 };
120 120
121 IN_PROC_BROWSER_TEST_F(ExtensionFileBrowserPrivateApiTest, FileBrowserMount) { 121 IN_PROC_BROWSER_TEST_F(ExtensionFileBrowserPrivateApiTest, FileBrowserMount) {
122 // We will call fileBrowserPrivate.unmountVolume once. To test that method, we 122 // We will call fileBrowserPrivate.unmountVolume once. To test that method, we
123 // check that UnmountPath is really called with the same value. 123 // check that UnmountPath is really called with the same value.
124 AddTmpMountPoint(); 124 AddTmpMountPoint();
125 EXPECT_CALL(mount_library_mock_, UnmountPath(_)) 125 EXPECT_CALL(*cros_disks_client_mock_, UnmountPath(_))
126 .Times(0); 126 .Times(0);
127 EXPECT_CALL(mount_library_mock_, UnmountPath(StrEq("/tmp/test_file.zip"))) 127 EXPECT_CALL(*cros_disks_client_mock_,
128 .Times(1); 128 UnmountPath(StrEq("/tmp/test_file.zip"))).Times(1);
129 129
130 EXPECT_CALL(mount_library_mock_, disks()) 130 EXPECT_CALL(*cros_disks_client_mock_, disks())
131 .WillRepeatedly(ReturnRef(volumes_)); 131 .WillRepeatedly(ReturnRef(volumes_));
132 132
133 ASSERT_TRUE(RunComponentExtensionTest("filebrowser_mount")) << message_; 133 ASSERT_TRUE(RunComponentExtensionTest("filebrowser_mount")) << message_;
134 } 134 }
135
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_file_browser_private_api.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698