Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: And another test Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698