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

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

Issue 10784035: Refactored SettingsFrontend and forwarding of calls to the backends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment Created 8 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 | 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_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/page_action_controller.h" 11 #include "chrome/browser/extensions/page_action_controller.h"
12 #include "chrome/browser/extensions/test_extension_system.h" 12 #include "chrome/browser/extensions/test_extension_system.h"
13 #include "chrome/browser/sessions/session_id.h" 13 #include "chrome/browser/sessions/session_id.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents.h"
15 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/test_tab_contents.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_builder.h" 17 #include "chrome/common/extensions/extension_builder.h"
18 #include "chrome/common/extensions/value_builder.h" 18 #include "chrome/common/extensions/value_builder.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread.h"
21 21
22 using content::BrowserThread; 22 using content::BrowserThread;
23 23
24 namespace extensions { 24 namespace extensions {
25 namespace { 25 namespace {
26 26
27 class PageActionControllerTest : public TabContentsTestHarness { 27 class PageActionControllerTest : public TabContentsTestHarness {
28 public: 28 public:
29 PageActionControllerTest() 29 PageActionControllerTest()
30 : ui_thread_(BrowserThread::UI, MessageLoop::current()) { 30 : ui_thread_(BrowserThread::UI, MessageLoop::current()),
31 } 31 file_thread_(BrowserThread::FILE, MessageLoop::current()) {}
32 32
33 virtual void SetUp() { 33 virtual void SetUp() OVERRIDE {
34 TabContentsTestHarness::SetUp(); 34 TabContentsTestHarness::SetUp();
35 // Create an ExtensionService so the PageActionController can find its 35 // Create an ExtensionService so the PageActionController can find its
36 // extensions. 36 // extensions.
37 CommandLine command_line(CommandLine::NO_PROGRAM); 37 CommandLine command_line(CommandLine::NO_PROGRAM);
38 extension_service_ = 38 extension_service_ =
39 static_cast<TestExtensionSystem*>( 39 static_cast<TestExtensionSystem*>(
40 ExtensionSystem::Get(tab_contents()->profile()))-> 40 ExtensionSystem::Get(tab_contents()->profile()))->
41 CreateExtensionService( 41 CreateExtensionService(
42 &command_line, FilePath(), false); 42 &command_line, FilePath(), false);
43 } 43 }
44 44
45 protected: 45 protected:
46 int tab_id() { 46 int tab_id() {
47 return SessionID::IdForTab(tab_contents()); 47 return SessionID::IdForTab(tab_contents());
48 } 48 }
49 49
50 ExtensionService* extension_service_; 50 ExtensionService* extension_service_;
51 51
52 private: 52 private:
53 content::TestBrowserThread ui_thread_; 53 content::TestBrowserThread ui_thread_;
54 content::TestBrowserThread file_thread_;
54 }; 55 };
55 56
56 TEST_F(PageActionControllerTest, NavigationClearsState) { 57 TEST_F(PageActionControllerTest, NavigationClearsState) {
57 scoped_refptr<const Extension> extension = 58 scoped_refptr<const Extension> extension =
58 ExtensionBuilder() 59 ExtensionBuilder()
59 .SetManifest(DictionaryBuilder() 60 .SetManifest(DictionaryBuilder()
60 .Set("name", "Extension with page action") 61 .Set("name", "Extension with page action")
61 .Set("version", "1.0.0") 62 .Set("version", "1.0.0")
62 .Set("manifest_version", 2) 63 .Set("manifest_version", 2)
63 .Set("permissions", ListBuilder() 64 .Set("permissions", ListBuilder()
(...skipping 15 matching lines...) Expand all
79 80
80 // Should discard the settings, and go back to the defaults. 81 // Should discard the settings, and go back to the defaults.
81 NavigateAndCommit(GURL("http://www.yahoo.com")); 82 NavigateAndCommit(GURL("http://www.yahoo.com"));
82 83
83 EXPECT_EQ("Hello", extension->page_action()->GetTitle(tab_id())); 84 EXPECT_EQ("Hello", extension->page_action()->GetTitle(tab_id()));
84 EXPECT_EQ(GURL(), extension->page_action()->GetPopupUrl(tab_id())); 85 EXPECT_EQ(GURL(), extension->page_action()->GetPopupUrl(tab_id()));
85 }; 86 };
86 87
87 } // namespace 88 } // namespace
88 } // namespace extensions 89 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_ui_unittest.cc ('k') | chrome/browser/extensions/script_badge_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698