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 #include "base/command_line.h" | 4 #include "base/command_line.h" |
5 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/timer.h" | 6 #include "base/timer.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/api/system_info_storage/storage_info_provide
r.h" | 8 #include "chrome/browser/extensions/api/system_info_storage/storage_info_provide
r.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.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/storage_monitor.h" | 12 #include "chrome/browser/storage_monitor/storage_monitor.h" |
13 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 13 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 | 16 |
17 using chrome::StorageMonitor; | 17 using chrome::StorageMonitor; |
18 using chrome::test::TestStorageMonitor; | 18 using chrome::test::TestStorageMonitor; |
19 using extensions::api::experimental_system_info_storage::ParseStorageUnitType; | 19 using extensions::api::experimental_system_info_storage::ParseStorageUnitType; |
20 using extensions::api::experimental_system_info_storage::StorageUnitInfo; | 20 using extensions::api::experimental_system_info_storage::StorageUnitInfo; |
21 using extensions::StorageInfoProvider; | 21 using extensions::StorageInfoProvider; |
22 using extensions::StorageInfo; | 22 using extensions::StorageInfo; |
| 23 using extensions::systeminfo::kStorageTypeFixed; |
| 24 using extensions::systeminfo::kStorageTypeRemovable; |
| 25 using extensions::systeminfo::kStorageTypeUnknown; |
23 | 26 |
24 struct TestUnitInfo { | 27 struct TestUnitInfo { |
25 std::string id; | 28 std::string id; |
26 std::string type; | 29 std::string type; |
27 double capacity; | 30 double capacity; |
28 double available_capacity; | 31 double available_capacity; |
29 // The change step of free space. | 32 // The change step of free space. |
30 int change_step; | 33 int change_step; |
31 }; | 34 }; |
32 | 35 |
33 struct TestUnitInfo kTestingData[] = { | 36 struct TestUnitInfo kTestingData[] = { |
34 {"0xbeaf", "unknown", 4098, 1000, 0}, | 37 {"0xbeaf", kStorageTypeUnknown, 4098, 1000, 0}, |
35 {"/home", "harddisk", 4098, 1000, 10}, | 38 {"/home", kStorageTypeFixed, 4098, 1000, 10}, |
36 {"/data", "harddisk", 10000, 1000, 4097} | 39 {"/data", kStorageTypeFixed, 10000, 1000, 4097} |
37 }; | 40 }; |
38 | 41 |
39 struct TestUnitInfo kRemovableStorageData[] = { | 42 struct TestUnitInfo kRemovableStorageData[] = { |
40 {"/media/usb1", "removable", 4098, 1000, 1} | 43 {"/media/usb1", kStorageTypeRemovable, 4098, 1000, 1} |
41 }; | 44 }; |
42 | 45 |
43 const char kRemovableStorageDeviceName[] = "deviceName"; | 46 const char kRemovableStorageDeviceName[] = "deviceName"; |
44 const char kRemovableStorageDeviceId[] = "path://0xbeaf1"; | 47 const char kRemovableStorageDeviceId[] = "path://0xbeaf1"; |
45 const base::FilePath::CharType kRemovableStorageLocation[] = | 48 const base::FilePath::CharType kRemovableStorageLocation[] = |
46 FILE_PATH_LITERAL("/media/usb1"); | 49 FILE_PATH_LITERAL("/media/usb1"); |
47 const size_t kTestingIntervalMS = 10; | 50 const size_t kTestingIntervalMS = 10; |
48 | 51 |
49 class TestStorageInfoProvider : public StorageInfoProvider { | 52 class TestStorageInfoProvider : public StorageInfoProvider { |
50 public: | 53 public: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 ASSERT_TRUE(attach_listener.WaitUntilSatisfied()); | 148 ASSERT_TRUE(attach_listener.WaitUntilSatisfied()); |
146 ProcessAttach(kRemovableStorageDeviceId, | 149 ProcessAttach(kRemovableStorageDeviceId, |
147 ASCIIToUTF16(kRemovableStorageDeviceName), | 150 ASCIIToUTF16(kRemovableStorageDeviceName), |
148 kRemovableStorageLocation); | 151 kRemovableStorageLocation); |
149 // Simulate triggering onDetached event. | 152 // Simulate triggering onDetached event. |
150 ASSERT_TRUE(detach_listener.WaitUntilSatisfied()); | 153 ASSERT_TRUE(detach_listener.WaitUntilSatisfied()); |
151 ProcessDetach(kRemovableStorageDeviceId); | 154 ProcessDetach(kRemovableStorageDeviceId); |
152 | 155 |
153 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 156 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
154 } | 157 } |
OLD | NEW |