summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_file_browser_private_apitest.cc
diff options
context:
space:
mode:
authortbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-16 01:01:40 +0000
committertbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-16 01:01:40 +0000
commit61334fa3ab0ace691821bc4e4cad2ad18e042a1a (patch)
tree89f582268d4a84aec406084597728c2175bfd5da /chrome/browser/extensions/extension_file_browser_private_apitest.cc
parent60e08298a2cc9578884ccf5efb2958f3e4a947a2 (diff)
downloadchromium_src-61334fa3ab0ace691821bc4e4cad2ad18e042a1a.zip
chromium_src-61334fa3ab0ace691821bc4e4cad2ad18e042a1a.tar.gz
chromium_src-61334fa3ab0ace691821bc4e4cad2ad18e042a1a.tar.bz2
Adding methods for unmounting a volume and fetching volume metadata to fileBrowserPrivate API
Both methods expect volume's devicePath to be passed to them, so file_browser_event_router has to pass it to the extension, too. BUG=chromium-os:14504, chromium-os:15665 TEST=Ran ExtensionFileBrowserPrivateApiTest.* (which is in this CL) Review URL: http://codereview.chromium.org/7109038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_file_browser_private_apitest.cc')
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_apitest.cc108
1 files changed, 108 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_file_browser_private_apitest.cc b/chrome/browser/extensions/extension_file_browser_private_apitest.cc
new file mode 100644
index 0000000..58d41c9
--- /dev/null
+++ b/chrome/browser/extensions/extension_file_browser_private_apitest.cc
@@ -0,0 +1,108 @@
+// Copyright (c) 2011 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/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/mock_mount_library.h"
+#include "chrome/browser/extensions/extension_apitest.h"
+
+using ::testing::_;
+using ::testing::ReturnRef;
+using ::testing::StrEq;
+
+class ExtensionFileBrowserPrivateApiTest : public ExtensionApiTest {
+ public:
+ ExtensionFileBrowserPrivateApiTest() {
+ mount_library_mock_.SetupDefaultReplies();
+
+ chromeos::CrosLibrary::Get()->GetTestApi()->SetMountLibrary(
+ &mount_library_mock_,
+ false); // We own the mock library object.
+
+ CreateVolumeMap();
+ }
+
+ virtual ~ExtensionFileBrowserPrivateApiTest() {
+ DeleteVolumeMap();
+ chromeos::CrosLibrary::Get()->GetTestApi()->SetMountLibrary(NULL, true);
+ }
+
+ private:
+ void CreateVolumeMap() {
+ // These have to be sync'd with values in filebrowser_mount extension.
+ volumes_.insert(
+ std::pair<std::string, chromeos::MountLibrary::Disk*>(
+ "device_path1",
+ new chromeos::MountLibrary::Disk("device_path1",
+ "mount_path1",
+ "system_path1",
+ "file_path1",
+ "device_label1",
+ "drive_label1",
+ "parent_path1",
+ chromeos::FLASH,
+ 1073741824,
+ false,
+ false,
+ false,
+ false)));
+ volumes_.insert(
+ std::pair<std::string, chromeos::MountLibrary::Disk*>(
+ "device_path2",
+ new chromeos::MountLibrary::Disk("device_path2",
+ "mount_path2",
+ "system_path2",
+ "file_path2",
+ "device_label2",
+ "drive_label2",
+ "parent_path2",
+ chromeos::HDD,
+ 47723,
+ true,
+ true,
+ true,
+ true)));
+ volumes_.insert(
+ std::pair<std::string, chromeos::MountLibrary::Disk*>(
+ "device_path3",
+ new chromeos::MountLibrary::Disk("device_path3",
+ "mount_path3",
+ "system_path3",
+ "file_path3",
+ "device_label3",
+ "drive_label3",
+ "parent_path3",
+ chromeos::OPTICAL,
+ 0,
+ true,
+ false,
+ false,
+ true)));
+ }
+
+ void DeleteVolumeMap() {
+ for (chromeos::MountLibrary::DiskMap::iterator it = volumes_.begin();
+ it != volumes_.end();
+ ++it) {
+ delete it->second;
+ }
+ volumes_.clear();
+ }
+
+ protected:
+ chromeos::MockMountLibrary mount_library_mock_;
+ chromeos::MountLibrary::DiskMap volumes_;
+};
+
+IN_PROC_BROWSER_TEST_F(ExtensionFileBrowserPrivateApiTest, FileBrowserMount) {
+ // We will call fileBrowserPrivate.unmountVolume once. To test that method, we
+ // check that UnmountPath is really called with the same value.
+ EXPECT_CALL(mount_library_mock_, UnmountPath(StrEq("devicePath1")))
+ .Times(1);
+
+ EXPECT_CALL(mount_library_mock_, disks())
+ .WillRepeatedly(ReturnRef(volumes_));
+
+ ASSERT_TRUE(RunComponentExtensionTest("filebrowser_mount")) << message_;
+}
+