| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "components/storage_monitor/storage_monitor.h" | 13 #include "components/storage_monitor/storage_monitor.h" |
| 14 #include "components/storage_monitor/test_storage_monitor.h" | 14 #include "components/storage_monitor/test_storage_monitor.h" |
| 15 #include "extensions/browser/api/system_storage/storage_api_test_util.h" | 15 #include "extensions/browser/api/system_storage/storage_api_test_util.h" |
| 16 #include "extensions/browser/api/system_storage/storage_info_provider.h" | 16 #include "extensions/browser/api/system_storage/storage_info_provider.h" |
| 17 #include "extensions/shell/test/shell_apitest.h" | 17 #include "extensions/shell/test/shell_apitest.h" |
| 18 #include "extensions/test/extension_test_message_listener.h" | 18 #include "extensions/test/extension_test_message_listener.h" |
| 19 #include "extensions/test/result_catcher.h" | 19 #include "extensions/test/result_catcher.h" |
| 20 | 20 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 std::unique_ptr<base::MessageLoop> message_loop_; | 105 std::unique_ptr<base::MessageLoop> message_loop_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, Storage) { | 108 IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, Storage) { |
| 109 SetUpAllMockStorageDevices(); | 109 SetUpAllMockStorageDevices(); |
| 110 TestStorageInfoProvider* provider = | 110 TestStorageInfoProvider* provider = |
| 111 new TestStorageInfoProvider(kTestingData, arraysize(kTestingData)); | 111 new TestStorageInfoProvider(kTestingData, arraysize(kTestingData)); |
| 112 extensions::StorageInfoProvider::InitializeForTesting(provider); | 112 extensions::StorageInfoProvider::InitializeForTesting(provider); |
| 113 std::vector<linked_ptr<ExtensionTestMessageListener>> device_ids_listeners; | 113 std::vector<std::unique_ptr<ExtensionTestMessageListener>> |
| 114 device_ids_listeners; |
| 114 for (size_t i = 0; i < arraysize(kTestingData); ++i) { | 115 for (size_t i = 0; i < arraysize(kTestingData); ++i) { |
| 115 linked_ptr<ExtensionTestMessageListener> listener( | 116 device_ids_listeners.push_back( |
| 116 new ExtensionTestMessageListener( | 117 base::MakeUnique<ExtensionTestMessageListener>( |
| 117 StorageMonitor::GetInstance()->GetTransientIdForDeviceId( | 118 StorageMonitor::GetInstance()->GetTransientIdForDeviceId( |
| 118 kTestingData[i].device_id), | 119 kTestingData[i].device_id), |
| 119 false)); | 120 false)); |
| 120 device_ids_listeners.push_back(listener); | |
| 121 } | 121 } |
| 122 ASSERT_TRUE(RunAppTest("system/storage")) << message_; | 122 ASSERT_TRUE(RunAppTest("system/storage")) << message_; |
| 123 for (size_t i = 0; i < device_ids_listeners.size(); ++i) | 123 for (size_t i = 0; i < device_ids_listeners.size(); ++i) |
| 124 EXPECT_TRUE(device_ids_listeners[i]->WaitUntilSatisfied()); | 124 EXPECT_TRUE(device_ids_listeners[i]->WaitUntilSatisfied()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, StorageAttachment) { | 127 IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, StorageAttachment) { |
| 128 extensions::ResultCatcher catcher; | 128 extensions::ResultCatcher catcher; |
| 129 ExtensionTestMessageListener attach_listener("attach", false); | 129 ExtensionTestMessageListener attach_listener("attach", false); |
| 130 ExtensionTestMessageListener detach_listener("detach", false); | 130 ExtensionTestMessageListener detach_listener("detach", false); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 142 removable_storage_transient_id, false); | 142 removable_storage_transient_id, false); |
| 143 | 143 |
| 144 // Simulate triggering onDetached event. | 144 // Simulate triggering onDetached event. |
| 145 ASSERT_TRUE(detach_listener.WaitUntilSatisfied()); | 145 ASSERT_TRUE(detach_listener.WaitUntilSatisfied()); |
| 146 DetachRemovableStorage(kRemovableStorageData.device_id); | 146 DetachRemovableStorage(kRemovableStorageData.device_id); |
| 147 | 147 |
| 148 ASSERT_TRUE(detach_device_id_listener.WaitUntilSatisfied()); | 148 ASSERT_TRUE(detach_device_id_listener.WaitUntilSatisfied()); |
| 149 | 149 |
| 150 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 150 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 151 } | 151 } |
| OLD | NEW |