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

Side by Side Diff: chromeos/disks/disk_mount_manager_unittest.cc

Issue 2230713003: Store correct read-only flag of mounted disks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 10 #include "chromeos/dbus/dbus_thread_manager.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // Holds information to create a DiskMOuntManager::MountPointInfo instance. 50 // Holds information to create a DiskMOuntManager::MountPointInfo instance.
51 struct TestMountPointInfo { 51 struct TestMountPointInfo {
52 const char* source_path; 52 const char* source_path;
53 const char* mount_path; 53 const char* mount_path;
54 chromeos::MountType mount_type; 54 chromeos::MountType mount_type;
55 chromeos::disks::MountCondition mount_condition; 55 chromeos::disks::MountCondition mount_condition;
56 }; 56 };
57 57
58 // List of disks held in DiskMountManager at the begining of the test. 58 // List of disks held in DiskMountManager at the begining of the test.
59 const TestDiskInfo kTestDisks[] = { 59 const TestDiskInfo kTestDisks[] = {
60 { 60 {
61 "/device/source_path", 61 "/device/source_path",
62 "/device/mount_path", 62 "/device/mount_path",
63 "/device/prefix/system_path", 63 "/device/prefix/system_path",
64 "/device/file_path", 64 "/device/file_path",
65 "/device/device_label", 65 "/device/device_label",
66 "/device/drive_label", 66 "/device/drive_label",
67 "/device/vendor_id", 67 "/device/vendor_id",
68 "/device/vendor_name", 68 "/device/vendor_name",
69 "/device/product_id", 69 "/device/product_id",
70 "/device/product_name", 70 "/device/product_name",
71 "/device/fs_uuid", 71 "/device/fs_uuid",
72 "/device/prefix", 72 "/device/prefix",
73 chromeos::DEVICE_TYPE_USB, 73 chromeos::DEVICE_TYPE_USB,
74 1073741824, // size in bytes 74 1073741824, // size in bytes
75 false, // is parent 75 false, // is parent
76 false, // is read only 76 false, // is read only
77 true, // has media 77 true, // has media
78 false, // is on boot device 78 false, // is on boot device
79 true, // is on removable device 79 true, // is on removable device
80 false // is hidden 80 false // is hidden
81 }, 81 },
82 {
83 "/device/source_path2",
84 "/device/mount_path2",
85 "/device/prefix/system_path2",
86 "/device/file_path2",
87 "/device/device_label2",
88 "/device/drive_label2",
89 "/device/vendor_id2",
90 "/device/vendor_name2",
91 "/device/product_id2",
92 "/device/product_name2",
93 "/device/fs_uuid2",
94 "/device/prefix2",
95 chromeos::DEVICE_TYPE_SD,
96 1073741824, // size in bytes
97 false, // is parent
98 false, // is read only
99 true, // has media
100 false, // is on boot device
101 true, // is on removable device
102 false // is hidden
103 },
82 }; 104 };
83 105
84 // List of mount points held in DiskMountManager at the begining of the test. 106 // List of mount points held in DiskMountManager at the begining of the test.
85 const TestMountPointInfo kTestMountPoints[] = { 107 const TestMountPointInfo kTestMountPoints[] = {
86 { 108 {
87 "/archive/source_path", 109 "/archive/source_path",
88 "/archive/mount_path", 110 "/archive/mount_path",
89 chromeos::MOUNT_TYPE_ARCHIVE, 111 chromeos::MOUNT_TYPE_ARCHIVE,
90 chromeos::disks::MOUNT_CONDITION_NONE 112 chromeos::disks::MOUNT_CONDITION_NONE
91 }, 113 },
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 EXPECT_EQ(2, fake_cros_disks_client_->format_call_count()); 593 EXPECT_EQ(2, fake_cros_disks_client_->format_call_count());
572 EXPECT_EQ("/device/source_path", 594 EXPECT_EQ("/device/source_path",
573 fake_cros_disks_client_->last_format_device_path()); 595 fake_cros_disks_client_->last_format_device_path());
574 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); 596 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem());
575 597
576 // Simulate cros_disks reporting success. 598 // Simulate cros_disks reporting success.
577 fake_cros_disks_client_->SendFormatCompletedEvent( 599 fake_cros_disks_client_->SendFormatCompletedEvent(
578 chromeos::FORMAT_ERROR_NONE, "/device/source_path"); 600 chromeos::FORMAT_ERROR_NONE, "/device/source_path");
579 } 601 }
580 602
603 TEST_F(DiskMountManagerTest, MountPath_RecordAccessMode) {
604 DiskMountManager* manager = DiskMountManager::GetInstance();
605 const std::string kSourcePath1 = "/device/source_path";
606 const std::string kSourcePath2 = "/device/source_path2";
607 const std::string kSourceFormat = "";
608 const std::string kMountLabel1 = "/device/mount_path1";
609 const std::string kMountLabel2 = "/device/mount_path2";
610
611 manager->MountPath(kSourcePath1, kSourceFormat, kMountLabel1,
612 chromeos::MOUNT_TYPE_DEVICE,
613 chromeos::MOUNT_ACCESS_MODE_READ_WRITE);
614 manager->MountPath(kSourcePath2, kSourceFormat, kMountLabel2,
615 chromeos::MOUNT_TYPE_DEVICE,
616 chromeos::MOUNT_ACCESS_MODE_READ_ONLY);
617 // Simulate cros_disks reporting mount completed.
618 fake_cros_disks_client_->SendMountCompletedEvent(
619 chromeos::MOUNT_ERROR_NONE, kSourcePath1, chromeos::MOUNT_TYPE_DEVICE,
620 kMountLabel1);
621 fake_cros_disks_client_->SendMountCompletedEvent(
622 chromeos::MOUNT_ERROR_NONE, kSourcePath2, chromeos::MOUNT_TYPE_DEVICE,
623 kMountLabel2);
624
625 const DiskMountManager::DiskMap& disks = manager->disks();
626 ASSERT_FALSE(disks.find(kSourcePath1) == disks.end());
satorux1 2016/08/12 02:47:52 how about: ASSERT_GT(disks.count(kSourcePath1), 0
yamaguchi 2016/08/15 15:32:48 Done.
627 EXPECT_FALSE(disks.find(kSourcePath1)->second->is_read_only());
628 ASSERT_FALSE(disks.find(kSourcePath2) == disks.end());
satorux1 2016/08/12 02:47:52 ditto
yamaguchi 2016/08/15 15:32:48 Done.
629 EXPECT_TRUE(disks.find(kSourcePath2)->second->is_read_only());
630 }
631
581 } // namespace 632 } // namespace
OLDNEW
« chromeos/disks/disk_mount_manager.cc ('K') | « chromeos/disks/disk_mount_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698