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

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager_unittest.cc

Issue 2401963002: Remount all removable storage devices upon policy update (Closed)
Patch Set: User ASSERT_EQ to avoid test crash. Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/file_manager/volume_manager.h" 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 if (secondary_observer.events()[i].type == 780 if (secondary_observer.events()[i].type ==
781 LoggingObserver::Event::VOLUME_MOUNTED) 781 LoggingObserver::Event::VOLUME_MOUNTED)
782 has_volume_mounted = true; 782 has_volume_mounted = true;
783 } 783 }
784 EXPECT_FALSE(has_volume_mounted); 784 EXPECT_FALSE(has_volume_mounted);
785 785
786 volume_manager()->RemoveObserver(&main_observer); 786 volume_manager()->RemoveObserver(&main_observer);
787 secondary.volume_manager()->RemoveObserver(&secondary_observer); 787 secondary.volume_manager()->RemoveObserver(&secondary_observer);
788 } 788 }
789 789
790 TEST_F(VolumeManagerTest, OnExternalStorageReadOnlyChanged) {
791 // Emulate updates of kExternalStorageReadOnly (change to true, then false).
792 profile()->GetPrefs()->SetBoolean(prefs::kExternalStorageReadOnly, true);
793 volume_manager()->OnExternalStorageReadOnlyChanged();
794 profile()->GetPrefs()->SetBoolean(prefs::kExternalStorageReadOnly, false);
795 volume_manager()->OnExternalStorageReadOnlyChanged();
796
797 // Verify that remount of removable disks is triggered for each update.
798 ASSERT_EQ(2U, disk_mount_manager_->remount_all_requests().size());
799 const FakeDiskMountManager::RemountAllRequest& remount_request1 =
800 disk_mount_manager_->remount_all_requests()[0];
801 EXPECT_EQ(chromeos::MOUNT_ACCESS_MODE_READ_ONLY,
802 remount_request1.access_mode);
803 const FakeDiskMountManager::RemountAllRequest& remount_request2 =
804 disk_mount_manager_->remount_all_requests()[1];
805 EXPECT_EQ(chromeos::MOUNT_ACCESS_MODE_READ_WRITE,
806 remount_request2.access_mode);
807 }
808
790 TEST_F(VolumeManagerTest, GetVolumeList) { 809 TEST_F(VolumeManagerTest, GetVolumeList) {
791 volume_manager()->Initialize(); // Adds "Downloads" 810 volume_manager()->Initialize(); // Adds "Downloads"
792 std::vector<base::WeakPtr<Volume>> volume_list = 811 std::vector<base::WeakPtr<Volume>> volume_list =
793 volume_manager()->GetVolumeList(); 812 volume_manager()->GetVolumeList();
794 ASSERT_EQ(1u, volume_list.size()); 813 ASSERT_EQ(1u, volume_list.size());
795 EXPECT_EQ("downloads:Downloads", volume_list[0]->volume_id()); 814 EXPECT_EQ("downloads:Downloads", volume_list[0]->volume_id());
796 EXPECT_EQ(VOLUME_TYPE_DOWNLOADS_DIRECTORY, volume_list[0]->type()); 815 EXPECT_EQ(VOLUME_TYPE_DOWNLOADS_DIRECTORY, volume_list[0]->type());
797 } 816 }
798 817
799 TEST_F(VolumeManagerTest, FindVolumeById) { 818 TEST_F(VolumeManagerTest, FindVolumeById) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 // Detach 923 // Detach
905 volume_manager()->OnRemovableStorageDetached(info); 924 volume_manager()->OnRemovableStorageDetached(info);
906 ASSERT_EQ(2u, observer.events().size()); 925 ASSERT_EQ(2u, observer.events().size());
907 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, 926 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED,
908 observer.events()[1].type); 927 observer.events()[1].type);
909 928
910 EXPECT_FALSE(volume.get()); 929 EXPECT_FALSE(volume.get());
911 } 930 }
912 931
913 } // namespace file_manager 932 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698