| OLD | NEW |
| 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" | 9 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
| 10 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 10 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 11 #include "chrome/browser/storage_monitor/storage_info.h" | 11 #include "chrome/browser/storage_monitor/storage_info.h" |
| 12 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 12 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace chrome { | |
| 16 | |
| 17 std::string GalleryName(const MediaGalleryPrefInfo& gallery) { | 15 std::string GalleryName(const MediaGalleryPrefInfo& gallery) { |
| 18 string16 name = gallery.GetGalleryDisplayName(); | 16 string16 name = gallery.GetGalleryDisplayName(); |
| 19 return UTF16ToASCII(name); | 17 return UTF16ToASCII(name); |
| 20 } | 18 } |
| 21 | 19 |
| 22 TEST(MediaGalleriesDialogControllerTest, TestNameGeneration) { | 20 TEST(MediaGalleriesDialogControllerTest, TestNameGeneration) { |
| 23 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); | 21 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); |
| 24 MediaGalleryPrefInfo gallery; | 22 MediaGalleryPrefInfo gallery; |
| 25 gallery.pref_id = 1; | 23 gallery.pref_id = 1; |
| 26 gallery.device_id = StorageInfo::MakeDeviceId( | 24 gallery.device_id = StorageInfo::MakeDeviceId( |
| 27 StorageInfo::FIXED_MASS_STORAGE, "/path/to/gallery"); | 25 StorageInfo::FIXED_MASS_STORAGE, "/path/to/gallery"); |
| 28 gallery.type = MediaGalleryPrefInfo::kAutoDetected; | 26 gallery.type = MediaGalleryPrefInfo::kAutoDetected; |
| 29 EXPECT_EQ("gallery", GalleryName(gallery)); | 27 EXPECT_EQ("gallery", GalleryName(gallery)); |
| 30 | 28 |
| 31 gallery.display_name = ASCIIToUTF16("override"); | 29 gallery.display_name = ASCIIToUTF16("override"); |
| 32 EXPECT_EQ("override", GalleryName(gallery)); | 30 EXPECT_EQ("override", GalleryName(gallery)); |
| 33 | 31 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 54 EXPECT_EQ("volume", GalleryName(gallery)); | 52 EXPECT_EQ("volume", GalleryName(gallery)); |
| 55 | 53 |
| 56 gallery.volume_label = string16(); | 54 gallery.volume_label = string16(); |
| 57 EXPECT_EQ("vendor, model", GalleryName(gallery)); | 55 EXPECT_EQ("vendor, model", GalleryName(gallery)); |
| 58 | 56 |
| 59 gallery.total_size_in_bytes = 1000000; | 57 gallery.total_size_in_bytes = 1000000; |
| 60 EXPECT_EQ("977 KB vendor, model", GalleryName(gallery)); | 58 EXPECT_EQ("977 KB vendor, model", GalleryName(gallery)); |
| 61 | 59 |
| 62 gallery.path = base::FilePath(FILE_PATH_LITERAL("sub/path")); | 60 gallery.path = base::FilePath(FILE_PATH_LITERAL("sub/path")); |
| 63 EXPECT_EQ("path - 977 KB vendor, model", GalleryName(gallery)); | 61 EXPECT_EQ("path - 977 KB vendor, model", GalleryName(gallery)); |
| 64 test::TestStorageMonitor::RemoveSingleton(); | 62 TestStorageMonitor::RemoveSingleton(); |
| 65 } | 63 } |
| 66 | |
| 67 } // namespace chrome | |
| OLD | NEW |