| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/api/system_storage/storage_api_test_util.h" | 9 #include "chrome/browser/extensions/api/system_storage/storage_api_test_util.h" |
| 10 #include "chrome/browser/extensions/api/system_storage/storage_info_provider.h" | 10 #include "chrome/browser/extensions/api/system_storage/storage_info_provider.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/extensions/extension_test_message_listener.h" | 12 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 13 #include "chrome/browser/storage_monitor/storage_info.h" | 13 #include "chrome/browser/storage_monitor/storage_info.h" |
| 14 #include "chrome/browser/storage_monitor/storage_monitor.h" | 14 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 15 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 15 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 using chrome::StorageMonitor; | |
| 20 using extensions::StorageUnitInfoList; | 19 using extensions::StorageUnitInfoList; |
| 21 using extensions::test::TestStorageUnitInfo; | 20 using extensions::test::TestStorageUnitInfo; |
| 22 using extensions::test::kRemovableStorageData; | 21 using extensions::test::kRemovableStorageData; |
| 23 | 22 |
| 24 const struct TestStorageUnitInfo kTestingData[] = { | 23 const struct TestStorageUnitInfo kTestingData[] = { |
| 25 {"dcim:device:001", "0xbeaf", 4098, 1000}, | 24 {"dcim:device:001", "0xbeaf", 4098, 1000}, |
| 26 {"path:device:002", "/home", 4098, 1000}, | 25 {"path:device:002", "/home", 4098, 1000}, |
| 27 {"path:device:003", "/data", 10000, 1000} | 26 {"path:device:003", "/data", 10000, 1000} |
| 28 }; | 27 }; |
| 29 | 28 |
| 30 } // namespace | 29 } // namespace |
| 31 | 30 |
| 32 class SystemStorageApiTest : public ExtensionApiTest { | 31 class SystemStorageApiTest : public ExtensionApiTest { |
| 33 public: | 32 public: |
| 34 SystemStorageApiTest() {} | 33 SystemStorageApiTest() {} |
| 35 virtual ~SystemStorageApiTest() {} | 34 virtual ~SystemStorageApiTest() {} |
| 36 | 35 |
| 37 virtual void SetUpOnMainThread() OVERRIDE { | 36 virtual void SetUpOnMainThread() OVERRIDE { |
| 38 chrome::test::TestStorageMonitor::CreateForBrowserTests(); | 37 TestStorageMonitor::CreateForBrowserTests(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 40 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 42 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 41 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 43 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); | 42 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); |
| 44 } | 43 } |
| 45 | 44 |
| 46 void SetUpAllMockStorageDevices() { | 45 void SetUpAllMockStorageDevices() { |
| 47 for (size_t i = 0; i < arraysize(kTestingData); ++i) { | 46 for (size_t i = 0; i < arraysize(kTestingData); ++i) { |
| 48 AttachRemovableStorage(kTestingData[i]); | 47 AttachRemovableStorage(kTestingData[i]); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 removable_storage_transient_id, false); | 98 removable_storage_transient_id, false); |
| 100 | 99 |
| 101 // Simulate triggering onDetached event. | 100 // Simulate triggering onDetached event. |
| 102 ASSERT_TRUE(detach_listener.WaitUntilSatisfied()); | 101 ASSERT_TRUE(detach_listener.WaitUntilSatisfied()); |
| 103 DetachRemovableStorage(kRemovableStorageData.device_id); | 102 DetachRemovableStorage(kRemovableStorageData.device_id); |
| 104 | 103 |
| 105 ASSERT_TRUE(detach_device_id_listener.WaitUntilSatisfied()); | 104 ASSERT_TRUE(detach_device_id_listener.WaitUntilSatisfied()); |
| 106 | 105 |
| 107 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 106 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 108 } | 107 } |
| OLD | NEW |