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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "chrome/browser/extensions/extension_service.h" 6 #include "chrome/browser/extensions/extension_service.h"
7 #include "chrome/browser/extensions/extension_web_ui.h" 7 #include "chrome/browser/extensions/extension_web_ui.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" 9 #include "chrome/browser/prefs/scoped_user_pref_update.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/tab_contents/tab_contents.h" 15 #include "content/browser/tab_contents/tab_contents.h"
16 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/web_contents.h"
18
19 using content::WebContents;
17 20
18 class ExtensionOverrideTest : public ExtensionApiTest { 21 class ExtensionOverrideTest : public ExtensionApiTest {
19 protected: 22 protected:
20 bool CheckHistoryOverridesContainsNoDupes() { 23 bool CheckHistoryOverridesContainsNoDupes() {
21 // There should be no duplicate entries in the preferences. 24 // There should be no duplicate entries in the preferences.
22 const DictionaryValue* overrides = 25 const DictionaryValue* overrides =
23 browser()->profile()->GetPrefs()->GetDictionary( 26 browser()->profile()->GetPrefs()->GetDictionary(
24 ExtensionWebUI::kExtensionURLOverrides); 27 ExtensionWebUI::kExtensionURLOverrides);
25 28
26 ListValue* values = NULL; 29 ListValue* values = NULL;
(...skipping 13 matching lines...) Expand all
40 } 43 }
41 44
42 return true; 45 return true;
43 } 46 }
44 47
45 #if defined(USE_VIRTUAL_KEYBOARD) 48 #if defined(USE_VIRTUAL_KEYBOARD)
46 // Navigate to the keyboard page, and ensure we have arrived at an 49 // Navigate to the keyboard page, and ensure we have arrived at an
47 // extension URL. 50 // extension URL.
48 void NavigateToKeyboard() { 51 void NavigateToKeyboard() {
49 ui_test_utils::NavigateToURL(browser(), GURL("chrome://keyboard/")); 52 ui_test_utils::NavigateToURL(browser(), GURL("chrome://keyboard/"));
50 TabContents* tab = browser()->GetSelectedTabContents(); 53 WebContents* tab = browser()->GetSelectedWebContents();
51 ASSERT_TRUE(tab->GetController().GetActiveEntry()); 54 ASSERT_TRUE(tab->GetController().GetActiveEntry());
52 EXPECT_TRUE(tab->GetController().GetActiveEntry()->url(). 55 EXPECT_TRUE(tab->GetController().GetActiveEntry()->url().
53 SchemeIs(chrome::kExtensionScheme)); 56 SchemeIs(chrome::kExtensionScheme));
54 } 57 }
55 #endif 58 #endif
56 }; 59 };
57 60
58 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { 61 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) {
59 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; 62 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_;
60 { 63 {
61 ResultCatcher catcher; 64 ResultCatcher catcher;
62 // Navigate to the new tab page. The overridden new tab page 65 // Navigate to the new tab page. The overridden new tab page
63 // will call chrome.test.notifyPass() . 66 // will call chrome.test.notifyPass() .
64 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); 67 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/"));
65 TabContents* tab = browser()->GetSelectedTabContents(); 68 WebContents* tab = browser()->GetSelectedWebContents();
66 ASSERT_TRUE(tab->GetController().GetActiveEntry()); 69 ASSERT_TRUE(tab->GetController().GetActiveEntry());
67 EXPECT_TRUE(tab->GetController().GetActiveEntry()->GetURL(). 70 EXPECT_TRUE(tab->GetController().GetActiveEntry()->GetURL().
68 SchemeIs(chrome::kExtensionScheme)); 71 SchemeIs(chrome::kExtensionScheme));
69 72
70 ASSERT_TRUE(catcher.GetNextResult()); 73 ASSERT_TRUE(catcher.GetNextResult());
71 } 74 }
72 75
73 // TODO(erikkay) Load a second extension with the same override. 76 // TODO(erikkay) Load a second extension with the same override.
74 // Verify behavior, then unload the first and verify behavior, etc. 77 // Verify behavior, then unload the first and verify behavior, etc.
75 } 78 }
76 79
77 #if defined(OS_MACOSX) 80 #if defined(OS_MACOSX)
78 // Hangy: http://crbug.com/70511 81 // Hangy: http://crbug.com/70511
79 #define MAYBE_OverrideNewtabIncognito DISABLED_OverrideNewtabIncognito 82 #define MAYBE_OverrideNewtabIncognito DISABLED_OverrideNewtabIncognito
80 #else 83 #else
81 #define MAYBE_OverrideNewtabIncognito OverrideNewtabIncognito 84 #define MAYBE_OverrideNewtabIncognito OverrideNewtabIncognito
82 #endif 85 #endif
83 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewtabIncognito) { 86 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewtabIncognito) {
84 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; 87 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_;
85 88
86 // Navigate an incognito tab to the new tab page. We should get the actual 89 // Navigate an incognito tab to the new tab page. We should get the actual
87 // new tab page because we can't load chrome-extension URLs in incognito. 90 // new tab page because we can't load chrome-extension URLs in incognito.
88 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), 91 ui_test_utils::OpenURLOffTheRecord(browser()->profile(),
89 GURL("chrome://newtab/")); 92 GURL("chrome://newtab/"));
90 Browser* otr_browser = BrowserList::FindTabbedBrowser( 93 Browser* otr_browser = BrowserList::FindTabbedBrowser(
91 browser()->profile()->GetOffTheRecordProfile(), false); 94 browser()->profile()->GetOffTheRecordProfile(), false);
92 TabContents* tab = otr_browser->GetSelectedTabContents(); 95 WebContents* tab = otr_browser->GetSelectedWebContents();
93 ASSERT_TRUE(tab->GetController().GetActiveEntry()); 96 ASSERT_TRUE(tab->GetController().GetActiveEntry());
94 EXPECT_FALSE(tab->GetController().GetActiveEntry()->GetURL(). 97 EXPECT_FALSE(tab->GetController().GetActiveEntry()->GetURL().
95 SchemeIs(chrome::kExtensionScheme)); 98 SchemeIs(chrome::kExtensionScheme));
96 } 99 }
97 100
98 // Times out consistently on Win, http://crbug.com/45173. 101 // Times out consistently on Win, http://crbug.com/45173.
99 #if defined(OS_WIN) 102 #if defined(OS_WIN)
100 #define MAYBE_OverrideHistory DISABLED_OverrideHistory 103 #define MAYBE_OverrideHistory DISABLED_OverrideHistory
101 #else 104 #else
102 #define MAYBE_OverrideHistory OverrideHistory 105 #define MAYBE_OverrideHistory OverrideHistory
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 176
174 // Unload the failing version. We should be back to passing now. 177 // Unload the failing version. We should be back to passing now.
175 UnloadExtension(extension->id()); 178 UnloadExtension(extension->id());
176 { 179 {
177 ResultCatcher catcher; 180 ResultCatcher catcher;
178 NavigateToKeyboard(); 181 NavigateToKeyboard();
179 ASSERT_TRUE(catcher.GetNextResult()); 182 ASSERT_TRUE(catcher.GetNextResult());
180 } 183 }
181 } 184 }
182 #endif 185 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_nacl_browsertest.cc ('k') | chrome/browser/extensions/extension_process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698