| 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 // SystemStorage eject API browser tests. | 5 // SystemStorage eject API browser tests. |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/storage_monitor/storage_info.h" | 10 #include "components/storage_monitor/storage_info.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 return extensions::ProcessManager::Get(browser_context()) | 52 return extensions::ProcessManager::Get(browser_context()) |
| 53 ->GetBackgroundHostForExtension(extension->id()) | 53 ->GetBackgroundHostForExtension(extension->id()) |
| 54 ->render_view_host(); | 54 ->render_view_host(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ExecuteCmdAndCheckReply(content::RenderViewHost* host, | 57 void ExecuteCmdAndCheckReply(content::RenderViewHost* host, |
| 58 const std::string& js_command, | 58 const std::string& js_command, |
| 59 const std::string& ok_message) { | 59 const std::string& ok_message) { |
| 60 ExtensionTestMessageListener listener(ok_message, false); | 60 ExtensionTestMessageListener listener(ok_message, false); |
| 61 host->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16(js_command)); | 61 host->GetMainFrame()->ExecuteJavaScriptForTests( |
| 62 base::ASCIIToUTF16(js_command)); |
| 62 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 63 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void Attach() { | 66 void Attach() { |
| 66 DCHECK(StorageMonitor::GetInstance()->IsInitialized()); | 67 DCHECK(StorageMonitor::GetInstance()->IsInitialized()); |
| 67 StorageMonitor::GetInstance()->receiver()->ProcessAttach( | 68 StorageMonitor::GetInstance()->receiver()->ProcessAttach( |
| 68 extensions::test::BuildStorageInfoFromTestStorageUnitInfo( | 69 extensions::test::BuildStorageInfoFromTestStorageUnitInfo( |
| 69 kRemovableStorageData)); | 70 kRemovableStorageData)); |
| 70 content::RunAllPendingInMessageLoop(); | 71 content::RunAllPendingInMessageLoop(); |
| 71 } | 72 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 100 EXPECT_EQ(kRemovableStorageData.device_id, monitor_->ejected_device()); | 101 EXPECT_EQ(kRemovableStorageData.device_id, monitor_->ejected_device()); |
| 101 | 102 |
| 102 Detach(); | 103 Detach(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 IN_PROC_BROWSER_TEST_F(SystemStorageEjectApiTest, EjectBadDeviceTest) { | 106 IN_PROC_BROWSER_TEST_F(SystemStorageEjectApiTest, EjectBadDeviceTest) { |
| 106 ExecuteCmdAndCheckReply(GetHost(), "ejectFailTest()", "eject_no_such_device"); | 107 ExecuteCmdAndCheckReply(GetHost(), "ejectFailTest()", "eject_no_such_device"); |
| 107 | 108 |
| 108 EXPECT_EQ("", monitor_->ejected_device()); | 109 EXPECT_EQ("", monitor_->ejected_device()); |
| 109 } | 110 } |
| OLD | NEW |