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

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

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT 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
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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/extensions/extension_action.h" 10 #include "chrome/browser/extensions/extension_action.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
24 24
25 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/chromeos/login/user_manager.h" 26 #include "chrome/browser/chromeos/login/user_manager.h"
27 #include "chrome/browser/chromeos/settings/cros_settings.h" 27 #include "chrome/browser/chromeos/settings/cros_settings.h"
28 #include "chrome/browser/chromeos/settings/device_settings_service.h" 28 #include "chrome/browser/chromeos/settings/device_settings_service.h"
29 #endif 29 #endif
30 30
31 using content::BrowserThread;
32
33 namespace extensions { 31 namespace extensions {
34 namespace { 32 namespace {
35 33
36 class PageActionControllerTest : public ChromeRenderViewHostTestHarness { 34 class PageActionControllerTest : public ChromeRenderViewHostTestHarness {
37 public: 35 protected:
38 PageActionControllerTest()
39 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
40 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {}
41
42 virtual void SetUp() OVERRIDE { 36 virtual void SetUp() OVERRIDE {
43 ChromeRenderViewHostTestHarness::SetUp(); 37 ChromeRenderViewHostTestHarness::SetUp();
38 #if defined OS_CHROMEOS
39 test_user_manager_.reset(new chromeos::ScopedTestUserManager());
40 #endif
44 TabHelper::CreateForWebContents(web_contents()); 41 TabHelper::CreateForWebContents(web_contents());
45 // Create an ExtensionService so the PageActionController can find its 42 // Create an ExtensionService so the PageActionController can find its
46 // extensions. 43 // extensions.
47 CommandLine command_line(CommandLine::NO_PROGRAM); 44 CommandLine command_line(CommandLine::NO_PROGRAM);
48 Profile* profile = 45 Profile* profile =
49 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 46 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
50 extension_service_ = static_cast<TestExtensionSystem*>( 47 extension_service_ = static_cast<TestExtensionSystem*>(
51 ExtensionSystem::Get(profile))->CreateExtensionService( 48 ExtensionSystem::Get(profile))->CreateExtensionService(
52 &command_line, base::FilePath(), false); 49 &command_line, base::FilePath(), false);
53 } 50 }
54 51
55 protected: 52 virtual void TearDown() OVERRIDE {
53 #if defined OS_CHROMEOS
54 test_user_manager_.reset();
55 #endif
56 ChromeRenderViewHostTestHarness::TearDown();
57 }
58
56 int tab_id() { 59 int tab_id() {
57 return SessionID::IdForTab(web_contents()); 60 return SessionID::IdForTab(web_contents());
58 } 61 }
59 62
60 ExtensionService* extension_service_; 63 ExtensionService* extension_service_;
61 64
62 private: 65 private:
63 content::TestBrowserThread ui_thread_;
64 content::TestBrowserThread file_thread_;
65
66 #if defined OS_CHROMEOS 66 #if defined OS_CHROMEOS
67 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 67 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
68 chromeos::ScopedTestCrosSettings test_cros_settings_; 68 chromeos::ScopedTestCrosSettings test_cros_settings_;
69 chromeos::ScopedTestUserManager test_user_manager_; 69 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
70 #endif 70 #endif
71 }; 71 };
72 72
73 TEST_F(PageActionControllerTest, NavigationClearsState) { 73 TEST_F(PageActionControllerTest, NavigationClearsState) {
74 scoped_refptr<const Extension> extension = 74 scoped_refptr<const Extension> extension =
75 ExtensionBuilder() 75 ExtensionBuilder()
76 .SetManifest(DictionaryBuilder() 76 .SetManifest(DictionaryBuilder()
77 .Set("name", "Extension with page action") 77 .Set("name", "Extension with page action")
78 .Set("version", "1.0.0") 78 .Set("version", "1.0.0")
79 .Set("manifest_version", 2) 79 .Set("manifest_version", 2)
(...skipping 25 matching lines...) Expand all
105 105
106 // Should discard the settings, and go back to the defaults. 106 // Should discard the settings, and go back to the defaults.
107 NavigateAndCommit(GURL("http://www.yahoo.com")); 107 NavigateAndCommit(GURL("http://www.yahoo.com"));
108 108
109 EXPECT_EQ("Hello", page_action.GetTitle(tab_id())); 109 EXPECT_EQ("Hello", page_action.GetTitle(tab_id()));
110 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id())); 110 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id()));
111 }; 111 };
112 112
113 } // namespace 113 } // namespace
114 } // namespace extensions 114 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698