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()->ExecuteJavaScriptForTests( | 61 host->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16(js_command)); |
62 base::ASCIIToUTF16(js_command)); | |
63 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 62 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
64 } | 63 } |
65 | 64 |
66 void Attach() { | 65 void Attach() { |
67 DCHECK(StorageMonitor::GetInstance()->IsInitialized()); | 66 DCHECK(StorageMonitor::GetInstance()->IsInitialized()); |
68 StorageMonitor::GetInstance()->receiver()->ProcessAttach( | 67 StorageMonitor::GetInstance()->receiver()->ProcessAttach( |
69 extensions::test::BuildStorageInfoFromTestStorageUnitInfo( | 68 extensions::test::BuildStorageInfoFromTestStorageUnitInfo( |
70 kRemovableStorageData)); | 69 kRemovableStorageData)); |
71 content::RunAllPendingInMessageLoop(); | 70 content::RunAllPendingInMessageLoop(); |
72 } | 71 } |
(...skipping 28 matching lines...) Expand all Loading... |
101 EXPECT_EQ(kRemovableStorageData.device_id, monitor_->ejected_device()); | 100 EXPECT_EQ(kRemovableStorageData.device_id, monitor_->ejected_device()); |
102 | 101 |
103 Detach(); | 102 Detach(); |
104 } | 103 } |
105 | 104 |
106 IN_PROC_BROWSER_TEST_F(SystemStorageEjectApiTest, EjectBadDeviceTest) { | 105 IN_PROC_BROWSER_TEST_F(SystemStorageEjectApiTest, EjectBadDeviceTest) { |
107 ExecuteCmdAndCheckReply(GetHost(), "ejectFailTest()", "eject_no_such_device"); | 106 ExecuteCmdAndCheckReply(GetHost(), "ejectFailTest()", "eject_no_such_device"); |
108 | 107 |
109 EXPECT_EQ("", monitor_->ejected_device()); | 108 EXPECT_EQ("", monitor_->ejected_device()); |
110 } | 109 } |
OLD | NEW |