| 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 | 4 |
| 5 #include "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_
private_api.h" | 7 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_
private_api.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| 11 #include "chrome/browser/extensions/extension_test_message_listener.h" | 11 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 12 #include "chrome/browser/storage_monitor/storage_info.h" | 12 #include "chrome/browser/storage_monitor/storage_info.h" |
| 13 #include "chrome/browser/storage_monitor/storage_monitor.h" | 13 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 14 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 14 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/test/browser_test_utils.h" | 21 #include "content/public/test/browser_test_utils.h" |
| 22 #include "url/gurl.h" | |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 // Id of test extension from | 25 // Id of test extension from |
| 27 // chrome/test/data/extensions/api_test/|kTestExtensionPath| | 26 // chrome/test/data/extensions/api_test/|kTestExtensionPath| |
| 28 const char kTestExtensionId[] = "lkegdcleigedmkiikoijjgfchobofdbe"; | 27 const char kTestExtensionId[] = "lkegdcleigedmkiikoijjgfchobofdbe"; |
| 29 const char kTestExtensionPath[] = "media_galleries_private/attachdetach"; | 28 const char kTestExtensionPath[] = "media_galleries_private/attachdetach"; |
| 30 | 29 |
| 31 // JS commands. | 30 // JS commands. |
| 32 const char kAddAttachListenerCmd[] = "addAttachListener()"; | 31 const char kAddAttachListenerCmd[] = "addAttachListener()"; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 80 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 82 } | 81 } |
| 83 | 82 |
| 84 void AttachDetach() { | 83 void AttachDetach() { |
| 85 Attach(); | 84 Attach(); |
| 86 Detach(); | 85 Detach(); |
| 87 } | 86 } |
| 88 | 87 |
| 89 void Attach() { | 88 void Attach() { |
| 90 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized()); | 89 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized()); |
| 91 chrome::StorageInfo info(device_id_, ASCIIToUTF16(kDeviceName), kDevicePath, | 90 chrome::StorageInfo info(device_id_, kDevicePath, |
| 92 string16(), string16(), string16(), 0); | 91 base::ASCIIToUTF16(kDeviceName), base::string16(), |
| 92 base::string16(), 0); |
| 93 chrome::StorageMonitor::GetInstance()->receiver()->ProcessAttach(info); | 93 chrome::StorageMonitor::GetInstance()->receiver()->ProcessAttach(info); |
| 94 content::RunAllPendingInMessageLoop(); | 94 content::RunAllPendingInMessageLoop(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void Detach() { | 97 void Detach() { |
| 98 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized()); | 98 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized()); |
| 99 chrome::StorageMonitor::GetInstance()->receiver()->ProcessDetach( | 99 chrome::StorageMonitor::GetInstance()->receiver()->ProcessDetach( |
| 100 device_id_); | 100 device_id_); |
| 101 content::RunAllPendingInMessageLoop(); | 101 content::RunAllPendingInMessageLoop(); |
| 102 } | 102 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 Attach(); | 176 Attach(); |
| 177 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied()); | 177 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied()); |
| 178 Detach(); | 178 Detach(); |
| 179 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied()); | 179 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied()); |
| 180 | 180 |
| 181 Attach(); | 181 Attach(); |
| 182 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied()); | 182 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied()); |
| 183 Detach(); | 183 Detach(); |
| 184 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied()); | 184 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied()); |
| 185 } | 185 } |
| OLD | NEW |