| OLD | NEW |
| 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 // MediaGalleriesPreferences unit tests. | 5 // MediaGalleriesPreferences unit tests. |
| 6 | 6 |
| 7 #include "chrome/browser/media_gallery/media_galleries_preferences.h" | 7 #include "chrome/browser/media_gallery/media_galleries_preferences.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 class MediaStorageUtilTest : public MediaStorageUtil { | 32 class MediaStorageUtilTest : public MediaStorageUtil { |
| 33 public: | 33 public: |
| 34 static void SetTestingMode() { | 34 static void SetTestingMode() { |
| 35 SetGetDeviceInfoFromPathFunctionForTesting( | 35 SetGetDeviceInfoFromPathFunctionForTesting( |
| 36 &GetDeviceInfoFromPathTestFunction); | 36 &GetDeviceInfoFromPathTestFunction); |
| 37 } | 37 } |
| 38 | 38 |
| 39 static void GetDeviceInfoFromPathTestFunction(const FilePath& path, | 39 static bool GetDeviceInfoFromPathTestFunction(const FilePath& path, |
| 40 std::string* device_id, | 40 std::string* device_id, |
| 41 string16* device_name, | 41 string16* device_name, |
| 42 FilePath* relative_path) { | 42 FilePath* relative_path) { |
| 43 if (device_id) | 43 if (device_id) |
| 44 *device_id = MakeDeviceId(FIXED_MASS_STORAGE, path.AsUTF8Unsafe()); | 44 *device_id = MakeDeviceId(FIXED_MASS_STORAGE, path.AsUTF8Unsafe()); |
| 45 if (device_name) | 45 if (device_name) |
| 46 *device_name = path.BaseName().LossyDisplayName(); | 46 *device_name = path.BaseName().LossyDisplayName(); |
| 47 if (relative_path) | 47 if (relative_path) |
| 48 *relative_path = FilePath(); | 48 *relative_path = FilePath(); |
| 49 return true; |
| 49 } | 50 } |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 class MediaGalleriesPreferencesTest : public testing::Test { | 53 class MediaGalleriesPreferencesTest : public testing::Test { |
| 53 public: | 54 public: |
| 54 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> | 55 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> |
| 55 DeviceIdPrefIdsMap; | 56 DeviceIdPrefIdsMap; |
| 56 | 57 |
| 57 MediaGalleriesPreferencesTest() | 58 MediaGalleriesPreferencesTest() |
| 58 : ui_thread_(content::BrowserThread::UI, &loop_), | 59 : ui_thread_(content::BrowserThread::UI, &loop_), |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // Check that adding one of them again works as expected. | 526 // Check that adding one of them again works as expected. |
| 526 MediaGalleryPrefId id = gallery_prefs()->AddGallery( | 527 MediaGalleryPrefId id = gallery_prefs()->AddGallery( |
| 527 device_id, device_name, relative_path, true /*user*/); | 528 device_id, device_name, relative_path, true /*user*/); |
| 528 EXPECT_EQ(dev2_path2_id, id); | 529 EXPECT_EQ(dev2_path2_id, id); |
| 529 Verify(); | 530 Verify(); |
| 530 } | 531 } |
| 531 | 532 |
| 532 } // namespace | 533 } // namespace |
| 533 | 534 |
| 534 } // namespace chrome | 535 } // namespace chrome |
| OLD | NEW |