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

Side by Side Diff: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc

Issue 17504004: Add test storage monitor for MediaGalleries Private API browser test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
21 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
22 23
23 namespace { 24 namespace {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 host->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(js_command)); 80 host->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(js_command));
80 EXPECT_TRUE(listener.WaitUntilSatisfied()); 81 EXPECT_TRUE(listener.WaitUntilSatisfied());
81 } 82 }
82 83
83 void AttachDetach() { 84 void AttachDetach() {
84 Attach(); 85 Attach();
85 Detach(); 86 Detach();
86 } 87 }
87 88
88 void Attach() { 89 void Attach() {
90 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized());
89 chrome::StorageInfo info(device_id_, ASCIIToUTF16(kDeviceName), kDevicePath, 91 chrome::StorageInfo info(device_id_, ASCIIToUTF16(kDeviceName), kDevicePath,
90 string16(), string16(), string16(), 0); 92 string16(), string16(), string16(), 0);
91 chrome::StorageMonitor::GetInstance()->receiver()->ProcessAttach(info); 93 chrome::StorageMonitor::GetInstance()->receiver()->ProcessAttach(info);
92 WaitForDeviceEvents(); 94 content::RunAllPendingInMessageLoop();
93 } 95 }
94 96
95 void Detach() { 97 void Detach() {
98 DCHECK(chrome::StorageMonitor::GetInstance()->IsInitialized());
96 chrome::StorageMonitor::GetInstance()->receiver()->ProcessDetach( 99 chrome::StorageMonitor::GetInstance()->receiver()->ProcessDetach(
97 device_id_); 100 device_id_);
98 WaitForDeviceEvents(); 101 content::RunAllPendingInMessageLoop();
99 } 102 }
100 103
101 private: 104 private:
102 void WaitForDeviceEvents() {
103 content::RunAllPendingInMessageLoop();
104 }
105
106 std::string device_id_; 105 std::string device_id_;
107 106
108 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateApiTest); 107 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateApiTest);
109 }; 108 };
110 109
111 // TODO(jschuh): Flaky on Win64 & Linux Aura build. crbug.com/247336 110 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateApiTest, DeviceAttachDetachEvents) {
112 #if (defined(OS_WIN) && defined(ARCH_CPU_X86_64)) || \ 111 scoped_ptr<chrome::test::TestStorageMonitor> monitor(
113 (defined(OS_LINUX) && defined(USE_AURA)) 112 chrome::test::TestStorageMonitor::CreateForBrowserTests());
114 #define MAYBE_DeviceAttachDetachEvents DISABLED_DeviceAttachDetachEvents 113 monitor->Init();
115 #else 114 monitor->MarkInitialized();
116 #define MAYBE_DeviceAttachDetachEvents DeviceAttachDetachEvents 115
117 #endif
118 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateApiTest,
119 MAYBE_DeviceAttachDetachEvents) {
120 // Setup. 116 // Setup.
121 const extensions::Extension* extension = 117 const extensions::Extension* extension =
122 LoadExtension(test_data_dir_.AppendASCII(kTestExtensionPath)); 118 LoadExtension(test_data_dir_.AppendASCII(kTestExtensionPath));
123 ASSERT_TRUE(extension); 119 ASSERT_TRUE(extension);
124 120
125 content::RenderViewHost* host = 121 content::RenderViewHost* host =
126 extensions::ExtensionSystem::Get(browser()->profile())-> 122 extensions::ExtensionSystem::Get(browser()->profile())->
127 process_manager()->GetBackgroundHostForExtension(extension->id())-> 123 process_manager()->GetBackgroundHostForExtension(extension->id())->
128 render_view_host(); 124 render_view_host();
129 ASSERT_TRUE(host); 125 ASSERT_TRUE(host);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 Attach(); 180 Attach();
185 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied()); 181 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
186 Detach(); 182 Detach();
187 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied()); 183 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
188 184
189 Attach(); 185 Attach();
190 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied()); 186 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
191 Detach(); 187 Detach();
192 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied()); 188 EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
193 } 189 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698