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

Side by Side Diff: chrome/browser/extensions/lazy_background_page_apitest.cc

Issue 10535077: TabContentsWrapper -> TabContents, part 12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #include "chrome/browser/extensions/browser_action_test_util.h" 9 #include "chrome/browser/extensions/browser_action_test_util.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Observe background page being created and closed after 104 // Observe background page being created and closed after
105 // the browser action is clicked. 105 // the browser action is clicked.
106 LazyBackgroundObserver page_complete; 106 LazyBackgroundObserver page_complete;
107 BrowserActionTestUtil(browser()).Press(0); 107 BrowserActionTestUtil(browser()).Press(0);
108 page_complete.Wait(); 108 page_complete.Wait();
109 109
110 // Background page created a new tab before it closed. 110 // Background page created a new tab before it closed.
111 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); 111 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_));
112 EXPECT_EQ(num_tabs_before + 1, browser()->tab_count()); 112 EXPECT_EQ(num_tabs_before + 1, browser()->tab_count());
113 EXPECT_EQ("chrome://chrome/extensions/", 113 EXPECT_EQ("chrome://chrome/extensions/",
114 browser()->GetSelectedWebContents()->GetURL().spec()); 114 browser()->GetActiveWebContents()->GetURL().spec());
115 } 115 }
116 116
117 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, 117 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest,
118 BrowserActionCreateTabAfterCallback) { 118 BrowserActionCreateTabAfterCallback) {
119 ASSERT_TRUE(LoadExtensionAndWait("browser_action_with_callback")); 119 ASSERT_TRUE(LoadExtensionAndWait("browser_action_with_callback"));
120 120
121 // Lazy Background Page doesn't exist yet. 121 // Lazy Background Page doesn't exist yet.
122 ExtensionProcessManager* pm = 122 ExtensionProcessManager* pm =
123 browser()->profile()->GetExtensionProcessManager(); 123 browser()->profile()->GetExtensionProcessManager();
124 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); 124 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 LazyBackgroundObserver page_complete; 185 LazyBackgroundObserver page_complete;
186 ResultCatcher catcher; 186 ResultCatcher catcher;
187 FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). 187 FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page").
188 AppendASCII("wait_for_view"); 188 AppendASCII("wait_for_view");
189 const Extension* extension = LoadExtension(extdir); 189 const Extension* extension = LoadExtension(extdir);
190 ASSERT_TRUE(extension); 190 ASSERT_TRUE(extension);
191 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 191 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
192 192
193 // The extension should've opened a new tab to an extension page. 193 // The extension should've opened a new tab to an extension page.
194 EXPECT_EQ(extension->GetResourceURL("extension_page.html").spec(), 194 EXPECT_EQ(extension->GetResourceURL("extension_page.html").spec(),
195 browser()->GetSelectedWebContents()->GetURL().spec()); 195 browser()->GetActiveWebContents()->GetURL().spec());
196 196
197 // Lazy Background Page still exists, because the extension created a new tab 197 // Lazy Background Page still exists, because the extension created a new tab
198 // to an extension page. 198 // to an extension page.
199 ExtensionProcessManager* pm = 199 ExtensionProcessManager* pm =
200 browser()->profile()->GetExtensionProcessManager(); 200 browser()->profile()->GetExtensionProcessManager();
201 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); 201 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_));
202 202
203 // Close the new tab. 203 // Close the new tab.
204 browser()->CloseTabContents(browser()->GetSelectedWebContents()); 204 browser()->CloseTabContents(browser()->GetActiveWebContents());
205 page_complete.Wait(); 205 page_complete.Wait();
206 206
207 // Lazy Background Page has been shut down. 207 // Lazy Background Page has been shut down.
208 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); 208 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_));
209 } 209 }
210 210
211 // Tests that the lazy background page stays alive until all network requests 211 // Tests that the lazy background page stays alive until all network requests
212 // are complete. 212 // are complete.
213 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForRequest) { 213 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForRequest) {
214 host_resolver()->AddRule("*", "127.0.0.1"); 214 host_resolver()->AddRule("*", "127.0.0.1");
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); 352 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_));
353 353
354 // The browser action has a new title. 354 // The browser action has a new title.
355 BrowserActionTestUtil browser_action(browser()); 355 BrowserActionTestUtil browser_action(browser());
356 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); 356 ASSERT_EQ(1, browser_action.NumberOfBrowserActions());
357 EXPECT_EQ("Success", browser_action.GetTooltip(0)); 357 EXPECT_EQ("Success", browser_action.GetTooltip(0));
358 } 358 }
359 359
360 // TODO: background page with timer. 360 // TODO: background page with timer.
361 // TODO: background page that interacts with popup. 361 // TODO: background page that interacts with popup.
OLDNEW
« no previous file with comments | « chrome/browser/extensions/isolated_app_browsertest.cc ('k') | chrome/browser/extensions/lazy_background_task_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698