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

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

Issue 57813003: Reland: Convert ExtensionProcessManager to BrowserContext, part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable on windows 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 | 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/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" 21 #include "chrome/browser/search/search.h"
22 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/omnibox/location_bar.h" 24 #include "chrome/browser/ui/omnibox/location_bar.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
28 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
29 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
30 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
32 #include "content/public/test/browser_test_utils.h" 31 #include "content/public/test/browser_test_utils.h"
32 #include "extensions/common/switches.h"
33 #include "net/dns/mock_host_resolver.h" 33 #include "net/dns/mock_host_resolver.h"
34 #include "net/test/embedded_test_server/embedded_test_server.h" 34 #include "net/test/embedded_test_server/embedded_test_server.h"
35 #include "url/gurl.h" 35 #include "url/gurl.h"
36 36
37 using extensions::Extension; 37 using extensions::Extension;
38 38
39 namespace { 39 namespace {
40 40
41 // This unfortunate bit of silliness is necessary when loading an extension in 41 // This unfortunate bit of silliness is necessary when loading an extension in
42 // incognito. The goal is to load the extension, enable incognito, then wait 42 // incognito. The goal is to load the extension, enable incognito, then wait
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 scoped_ptr<LazyBackgroundObserver> incognito_complete_; 74 scoped_ptr<LazyBackgroundObserver> incognito_complete_;
75 }; 75 };
76 76
77 } // namespace 77 } // namespace
78 78
79 class LazyBackgroundPageApiTest : public ExtensionApiTest { 79 class LazyBackgroundPageApiTest : public ExtensionApiTest {
80 public: 80 public:
81 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 81 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
82 ExtensionApiTest::SetUpCommandLine(command_line); 82 ExtensionApiTest::SetUpCommandLine(command_line);
83 // Set shorter delays to prevent test timeouts. 83 // Set shorter delays to prevent test timeouts.
84 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1"); 84 command_line->AppendSwitchASCII(
85 command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1"); 85 extensions::switches::kEventPageIdleTime, "1");
86 command_line->AppendSwitchASCII(
87 extensions::switches::kEventPageSuspendingTime, "1");
86 } 88 }
87 89
88 // Loads the extension, which temporarily starts the lazy background page 90 // Loads the extension, which temporarily starts the lazy background page
89 // to dispatch the onInstalled event. We wait until it shuts down again. 91 // to dispatch the onInstalled event. We wait until it shuts down again.
90 const Extension* LoadExtensionAndWait(const std::string& test_name) { 92 const Extension* LoadExtensionAndWait(const std::string& test_name) {
91 LazyBackgroundObserver page_complete; 93 LazyBackgroundObserver page_complete;
92 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). 94 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page").
93 AppendASCII(test_name); 95 AppendASCII(test_name);
94 const Extension* extension = LoadExtension(extdir); 96 const Extension* extension = LoadExtension(extdir);
95 if (extension) 97 if (extension)
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 511
510 // Tests that the lazy background page will be unloaded if the onSuspend event 512 // Tests that the lazy background page will be unloaded if the onSuspend event
511 // handler calls an API function such as chrome.storage.local.set(). 513 // handler calls an API function such as chrome.storage.local.set().
512 // See: http://crbug.com/296834 514 // See: http://crbug.com/296834
513 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { 515 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) {
514 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); 516 EXPECT_TRUE(LoadExtensionAndWait("on_suspend"));
515 } 517 }
516 518
517 // TODO: background page with timer. 519 // TODO: background page with timer.
518 // TODO: background page that interacts with popup. 520 // TODO: background page that interacts with popup.
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_process_manager_unittest.cc ('k') | chrome/browser/extensions/notifications_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698