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

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

Issue 16703025: [StorageMonitor] Move StorageMonitor ownership to BrowserProcessImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // MediaGalleriesPrivate eject API browser tests. 5 // MediaGalleriesPrivate 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 "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 } // namespace 47 } // namespace
48 48
49 49
50 /////////////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////////////
51 // MediaGalleriesPrivateEjectApiTest // 51 // MediaGalleriesPrivateEjectApiTest //
52 /////////////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////////////
53 53
54 class MediaGalleriesPrivateEjectApiTest : public ExtensionApiTest { 54 class MediaGalleriesPrivateEjectApiTest : public ExtensionApiTest {
55 public: 55 public:
56 MediaGalleriesPrivateEjectApiTest() : device_id_(GetDeviceId()) {} 56 MediaGalleriesPrivateEjectApiTest()
57 : device_id_(GetDeviceId()), monitor_(NULL) {}
57 virtual ~MediaGalleriesPrivateEjectApiTest() {} 58 virtual ~MediaGalleriesPrivateEjectApiTest() {}
58 59
59 protected: 60 protected:
60 // ExtensionApiTest overrides. 61 // ExtensionApiTest overrides.
61 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 62 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
62 ExtensionApiTest::SetUpCommandLine(command_line); 63 ExtensionApiTest::SetUpCommandLine(command_line);
63 command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID, 64 command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID,
64 kTestExtensionId); 65 kTestExtensionId);
65 } 66 }
66 67
68 virtual void SetUpOnMainThread() OVERRIDE {
69 monitor_ = chrome::test::TestStorageMonitor::CreateForBrowserTests();
70 ExtensionApiTest::SetUpOnMainThread();
71 }
72
67 content::RenderViewHost* GetHost() { 73 content::RenderViewHost* GetHost() {
68 const extensions::Extension* extension = 74 const extensions::Extension* extension =
69 LoadExtension(test_data_dir_.AppendASCII(kTestExtensionPath)); 75 LoadExtension(test_data_dir_.AppendASCII(kTestExtensionPath));
70 return extensions::ExtensionSystem::Get(browser()->profile())-> 76 return extensions::ExtensionSystem::Get(browser()->profile())->
71 process_manager()->GetBackgroundHostForExtension(extension->id())-> 77 process_manager()->GetBackgroundHostForExtension(extension->id())->
72 render_view_host(); 78 render_view_host();
73 } 79 }
74 80
75 void ExecuteCmdAndCheckReply(content::RenderViewHost* host, 81 void ExecuteCmdAndCheckReply(content::RenderViewHost* host,
76 const std::string& js_command, 82 const std::string& js_command,
(...skipping 19 matching lines...) Expand all
96 } 102 }
97 103
98 static std::string GetDeviceId() { 104 static std::string GetDeviceId() {
99 return chrome::StorageInfo::MakeDeviceId( 105 return chrome::StorageInfo::MakeDeviceId(
100 chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, kDeviceId); 106 chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, kDeviceId);
101 } 107 }
102 108
103 protected: 109 protected:
104 const std::string device_id_; 110 const std::string device_id_;
105 111
112 // Pointer to the storage monitor owned by the browser process.
vandebo (ex-Chrome) 2013/07/09 21:14:11 nit: "Owned by BrowserProcessImpl."
Greg Billock 2013/07/09 21:29:06 or the testing mock... I think this gets a bit too
vandebo (ex-Chrome) 2013/07/10 16:57:45 Then is a comment needed? "Pointer to the storage
Greg Billock 2013/07/10 21:11:16 ok, I'll kill these off.
113 chrome::test::TestStorageMonitor* monitor_;
114
106 private: 115 private:
107 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateEjectApiTest); 116 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateEjectApiTest);
108 }; 117 };
109 118
110 119
111 /////////////////////////////////////////////////////////////////////////////// 120 ///////////////////////////////////////////////////////////////////////////////
112 // TESTS // 121 // TESTS //
113 /////////////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////////////
114 123
115 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateEjectApiTest, EjectTest) { 124 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateEjectApiTest, EjectTest) {
116 scoped_ptr<chrome::test::TestStorageMonitor> monitor(
117 chrome::test::TestStorageMonitor::CreateForBrowserTests());
118 monitor->Init();
119 monitor->MarkInitialized();
120
121 content::RenderViewHost* host = GetHost(); 125 content::RenderViewHost* host = GetHost();
122 ExecuteCmdAndCheckReply(host, kAddAttachListenerCmd, kAddAttachListenerOk); 126 ExecuteCmdAndCheckReply(host, kAddAttachListenerCmd, kAddAttachListenerOk);
123 127
124 // Attach / detach 128 // Attach / detach
125 const std::string expect_attach_msg = 129 const std::string expect_attach_msg =
126 base::StringPrintf("%s,%s", kAttachTestOk, kDeviceName); 130 base::StringPrintf("%s,%s", kAttachTestOk, kDeviceName);
127 ExtensionTestMessageListener attach_finished_listener(expect_attach_msg, 131 ExtensionTestMessageListener attach_finished_listener(expect_attach_msg,
128 false /* no reply */); 132 false /* no reply */);
129 Attach(); 133 Attach();
130 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied()); 134 EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
131 135
132 ExecuteCmdAndCheckReply(host, kEjectTestCmd, kEjectListenerOk); 136 ExecuteCmdAndCheckReply(host, kEjectTestCmd, kEjectListenerOk);
133 EXPECT_EQ(device_id_, monitor->ejected_device()); 137 EXPECT_EQ(device_id_, monitor_->ejected_device());
134 138
135 Detach(); 139 Detach();
136 } 140 }
137 141
138 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateEjectApiTest, EjectBadDeviceTest) { 142 IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateEjectApiTest, EjectBadDeviceTest) {
139 scoped_ptr<chrome::test::TestStorageMonitor> monitor(
140 chrome::test::TestStorageMonitor::CreateForBrowserTests());
141 monitor->Init();
142 monitor->MarkInitialized();
143
144 ExecuteCmdAndCheckReply(GetHost(), kEjectFailTestCmd, kEjectFailListenerOk); 143 ExecuteCmdAndCheckReply(GetHost(), kEjectFailTestCmd, kEjectFailListenerOk);
145 144
146 EXPECT_EQ("", monitor->ejected_device()); 145 EXPECT_EQ("", monitor_->ejected_device());
147 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698