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

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

Issue 58903004: InstantExtended: update tests for Instant Extended (part 2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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) 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/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" 10 #include "chrome/browser/bookmarks/bookmark_test_helpers.h"
11 #include "chrome/browser/bookmarks/bookmark_utils.h" 11 #include "chrome/browser/bookmarks/bookmark_utils.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/extensions/browser_action_test_util.h" 13 #include "chrome/browser/extensions/browser_action_test_util.h"
14 #include "chrome/browser/extensions/extension_apitest.h" 14 #include "chrome/browser/extensions/extension_apitest.h"
15 #include "chrome/browser/extensions/extension_host.h" 15 #include "chrome/browser/extensions/extension_host.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h" 17 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/browser/extensions/extension_test_message_listener.h" 18 #include "chrome/browser/extensions/extension_test_message_listener.h"
19 #include "chrome/browser/extensions/lazy_background_page_test_util.h" 19 #include "chrome/browser/extensions/lazy_background_page_test_util.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/search/search.h"
22 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/omnibox/location_bar.h" 23 #include "chrome/browser/ui/omnibox/location_bar.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
26 #include "chrome/common/extensions/extension.h" 25 #include "chrome/common/extensions/extension.h"
27 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
28 #include "chrome/test/base/ui_test_utils.h" 27 #include "chrome/test/base/ui_test_utils.h"
29 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
31 #include "content/public/test/browser_test_utils.h" 30 #include "content/public/test/browser_test_utils.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, MAYBE_WaitForNTP) { 279 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, MAYBE_WaitForNTP) {
281 LazyBackgroundObserver lazybg; 280 LazyBackgroundObserver lazybg;
282 ResultCatcher catcher; 281 ResultCatcher catcher;
283 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). 282 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page").
284 AppendASCII("wait_for_ntp"); 283 AppendASCII("wait_for_ntp");
285 const Extension* extension = LoadExtension(extdir); 284 const Extension* extension = LoadExtension(extdir);
286 ASSERT_TRUE(extension); 285 ASSERT_TRUE(extension);
287 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 286 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
288 287
289 // The extension should've opened a new tab to an extension page. 288 // The extension should've opened a new tab to an extension page.
290 EXPECT_TRUE(chrome::IsNTPURL( 289 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
291 browser()->tab_strip_model()->GetActiveWebContents()->GetURL(), 290 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
292 browser()->profile()));
293 291
294 // Lazy Background Page still exists, because the extension created a new tab 292 // Lazy Background Page still exists, because the extension created a new tab
295 // to an extension page. 293 // to an extension page.
296 extensions::ProcessManager* pm = 294 extensions::ProcessManager* pm =
297 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 295 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
298 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 296 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
299 297
300 // Navigate away from the NTP, which should close the event page. 298 // Navigate away from the NTP, which should close the event page.
301 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 299 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
302 lazybg.Wait(); 300 lazybg.Wait();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 509
512 // Tests that the lazy background page will be unloaded if the onSuspend event 510 // Tests that the lazy background page will be unloaded if the onSuspend event
513 // handler calls an API function such as chrome.storage.local.set(). 511 // handler calls an API function such as chrome.storage.local.set().
514 // See: http://crbug.com/296834 512 // See: http://crbug.com/296834
515 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { 513 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) {
516 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); 514 EXPECT_TRUE(LoadExtensionAndWait("on_suspend"));
517 } 515 }
518 516
519 // TODO: background page with timer. 517 // TODO: background page with timer.
520 // TODO: background page that interacts with popup. 518 // TODO: background page that interacts with popup.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698