| Index: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc
|
| diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc
|
| index 05dffbe25b09047636c5e52be05867c4dcecf1e2..51ccbd2ad9740605b76b7ddc0ff61574f976d831 100644
|
| --- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc
|
| +++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc
|
| @@ -80,20 +80,27 @@ class MediaGalleriesPrivateApiTest : public ExtensionApiTest {
|
| EXPECT_TRUE(listener.WaitUntilSatisfied());
|
| }
|
|
|
| - void AttachDetach() {
|
| - Attach();
|
| - Detach();
|
| - }
|
| -
|
| - void Attach() {
|
| + void Attach(bool listening) {
|
| + const std::string expect_attach_msg =
|
| + base::StringPrintf("%s,%s", kAttachTestOk, kDeviceName);
|
| + ExtensionTestMessageListener attach_finished_listener(
|
| + expect_attach_msg,
|
| + false /* no reply */);
|
| base::SystemMonitor::Get()->ProcessRemovableStorageAttached(
|
| device_id_, ASCIIToUTF16(kDeviceName), kDevicePath);
|
| WaitForDeviceEvents();
|
| + if (listening)
|
| + EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
|
| }
|
|
|
| - void Detach() {
|
| + void Detach(bool listening) {
|
| + ExtensionTestMessageListener detach_finished_listener(
|
| + kDetachTestOk,
|
| + false /* no reply */);
|
| base::SystemMonitor::Get()->ProcessRemovableStorageDetached(device_id_);
|
| WaitForDeviceEvents();
|
| + if (listening)
|
| + EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
|
| }
|
|
|
| private:
|
| @@ -119,49 +126,41 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateApiTest, DeviceAttachDetachEvents) {
|
| ASSERT_TRUE(host);
|
|
|
| // No listeners, attach and detach a couple times.
|
| - AttachDetach();
|
| - AttachDetach();
|
| + Attach(false);
|
| + Detach(false);
|
| + Attach(false);
|
| + Detach(false);
|
|
|
| // Add attach listener.
|
| ChangeListener(host, kAddAttachListenerCmd, kAddAttachListenerOk);
|
|
|
| // Attach / detach
|
| - const std::string expect_attach_msg =
|
| - base::StringPrintf("%s,%s", kAttachTestOk, kDeviceName);
|
| - ExtensionTestMessageListener attach_finished_listener(expect_attach_msg,
|
| - false /* no reply */);
|
| - Attach();
|
| - EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
|
| - Detach();
|
| + Attach(true);
|
| + Detach(false);
|
|
|
| // Attach / detach
|
| - Attach();
|
| - EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
|
| - // Detach
|
| - Detach();
|
| + Attach(true);
|
| + Detach(false);
|
|
|
| // Remove attach listener.
|
| ChangeListener(host, kRemoveAttachListenerCmd, kRemoveAttachListenerOk);
|
|
|
| // No listeners, attach and detach a couple times.
|
| - AttachDetach();
|
| - AttachDetach();
|
| + Attach(false);
|
| + Detach(false);
|
| + Attach(false);
|
| + Detach(false);
|
|
|
| // Add detach listener.
|
| ChangeListener(host, kAddDummyDetachListenerCmd, kAddDummyDetachListenerOk);
|
|
|
| // Attach / detach
|
| - Attach();
|
| -
|
| - ExtensionTestMessageListener detach_finished_listener(kDetachTestOk,
|
| - false /* no reply */);
|
| - Detach();
|
| - EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
|
| + Attach(false);
|
| + Detach(true);
|
|
|
| // Attach / detach
|
| - Attach();
|
| - Detach();
|
| - EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
|
| + Attach(false);
|
| + Detach(true);
|
|
|
| // Switch ok dummy detach listener for the regular one.
|
| ChangeListener(host, kRemoveDummyDetachListenerCmd,
|
| @@ -171,13 +170,10 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateApiTest, DeviceAttachDetachEvents) {
|
| // Add attach listener.
|
| ChangeListener(host, kAddAttachListenerCmd, kAddAttachListenerOk);
|
|
|
| - Attach();
|
| - EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
|
| - Detach();
|
| - EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
|
| + Attach(true);
|
| + Detach(true);
|
|
|
| - Attach();
|
| - EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
|
| - Detach();
|
| - EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
|
| + Attach(true);
|
| + Detach(true);
|
| + CloseShellWindowsAndWaitForAppToExit();
|
| }
|
|
|