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

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

Issue 164458: Land http://codereview.chromium.org/159067: (Closed)
Patch Set: undo docs Created 11 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/ref_counted.h" 5 #include "base/ref_counted.h"
6 #include "chrome/browser/browser.h" 6 #include "chrome/browser/browser.h"
7 #include "chrome/browser/browser_list.h" 7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/renderer_host/render_view_host.h" 8 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
(...skipping 30 matching lines...) Expand all
41 return host; 41 return host;
42 } 42 }
43 43
44 // Tests that toolstrips initializes properly and can run basic extension js. 44 // Tests that toolstrips initializes properly and can run basic extension js.
45 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Toolstrip) { 45 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Toolstrip) {
46 FilePath extension_test_data_dir = test_data_dir_.AppendASCII("good"). 46 FilePath extension_test_data_dir = test_data_dir_.AppendASCII("good").
47 AppendASCII("Extensions").AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj"). 47 AppendASCII("Extensions").AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj").
48 AppendASCII("1.0.0.0"); 48 AppendASCII("1.0.0.0");
49 ASSERT_TRUE(LoadExtension(extension_test_data_dir)); 49 ASSERT_TRUE(LoadExtension(extension_test_data_dir));
50 50
51 // At this point, there should be two ExtensionHosts loaded because this 51 // At this point, there should be three ExtensionHosts loaded because this
52 // extension has two toolstrips. Find the one that is hosting toolstrip1.html. 52 // extension has two toolstrips and one background page. Find the one that is
53 // hosting toolstrip1.html.
53 ExtensionProcessManager* manager = 54 ExtensionProcessManager* manager =
54 browser()->profile()->GetExtensionProcessManager(); 55 browser()->profile()->GetExtensionProcessManager();
55 ExtensionHost* host = FindHostWithPath(manager, "/toolstrip1.html", 2); 56 ExtensionHost* host = FindHostWithPath(manager, "/toolstrip1.html", 3);
56 57
57 // Tell it to run some JavaScript that tests that basic extension code works. 58 // Tell it to run some JavaScript that tests that basic extension code works.
58 bool result = false; 59 bool result = false;
59 ui_test_utils::ExecuteJavaScriptAndExtractBool( 60 ui_test_utils::ExecuteJavaScriptAndExtractBool(
60 host->render_view_host(), L"", L"testTabsAPI()", &result); 61 host->render_view_host(), L"", L"testTabsAPI()", &result);
61 EXPECT_TRUE(result); 62 EXPECT_TRUE(result);
62 63
63 #if defined(OS_WIN) 64 #if defined(OS_WIN)
64 // Test for compact language detection API. First navigate to a (static) html 65 // Test for compact language detection API. First navigate to a (static) html
65 // file with a French sentence. Then, run the test API in toolstrip1.html to 66 // file with a French sentence. Then, run the test API in toolstrip1.html to
66 // actually call the language detection API through the existing extension, 67 // actually call the language detection API through the existing extension,
67 // and verify that the language returned is indeed French. 68 // and verify that the language returned is indeed French.
68 FilePath language_url = extension_test_data_dir.AppendASCII( 69 FilePath language_url = extension_test_data_dir.AppendASCII(
69 "french_sentence.html"); 70 "french_sentence.html");
70 ui_test_utils::NavigateToURL( 71 ui_test_utils::NavigateToURL(
71 browser(), 72 browser(),
72 GURL(language_url.ToWStringHack())); 73 GURL(language_url.ToWStringHack()));
73 74
74 ui_test_utils::ExecuteJavaScriptAndExtractBool( 75 ui_test_utils::ExecuteJavaScriptAndExtractBool(
75 host->render_view_host(), L"", L"testTabsLanguageAPI()", &result); 76 host->render_view_host(), L"", L"testTabsLanguageAPI()", &result);
76 EXPECT_TRUE(result); 77 EXPECT_TRUE(result);
77 #endif 78 #endif
78 } 79 }
79 80
81 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ExtensionViews) {
82 FilePath extension_test_data_dir = test_data_dir_.AppendASCII("good").
83 AppendASCII("Extensions").AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj").
84 AppendASCII("1.0.0.0");
85 ASSERT_TRUE(LoadExtension(extension_test_data_dir));
86
87 // At this point, there should be three ExtensionHosts loaded because this
88 // extension has two toolstrips and one background page. Find the one that is
89 // hosting toolstrip1.html.
90 ExtensionProcessManager* manager =
91 browser()->profile()->GetExtensionProcessManager();
92 ExtensionHost* host = FindHostWithPath(manager, "/toolstrip1.html", 3);
93
94 FilePath gettabs_url = extension_test_data_dir.AppendASCII(
95 "test_gettabs.html");
96 ui_test_utils::NavigateToURL(
97 browser(),
98 GURL(gettabs_url.ToWStringHack()));
99
100 bool result = false;
101 ui_test_utils::ExecuteJavaScriptAndExtractBool(
102 host->render_view_host(), L"", L"testgetToolstripsAPI()", &result);
103 EXPECT_TRUE(result);
104
105 result = false;
106 ui_test_utils::ExecuteJavaScriptAndExtractBool(
107 host->render_view_host(), L"", L"testgetBackgroundPageAPI()", &result);
108 EXPECT_TRUE(result);
109
110 ui_test_utils::NavigateToURL(
111 browser(),
112 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
113 "test_gettabs.html"));
114 result = false;
115 ui_test_utils::ExecuteJavaScriptAndExtractBool(
116 host->render_view_host(), L"", L"testgetTabContentsesAPI()", &result);
117 EXPECT_TRUE(result);
118 }
119
80 // Tests that the ExtensionShelf initializes properly, notices that 120 // Tests that the ExtensionShelf initializes properly, notices that
81 // an extension loaded and has a view available, and then sets that up 121 // an extension loaded and has a view available, and then sets that up
82 // properly. 122 // properly.
83 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Shelf) { 123 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Shelf) {
84 // When initialized, there are no extension views and the preferred height 124 // When initialized, there are no extension views and the preferred height
85 // should be zero. 125 // should be zero.
86 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); 126 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
87 ExtensionShelf* shelf = browser_view->extension_shelf(); 127 ExtensionShelf* shelf = browser_view->extension_shelf();
88 ASSERT_TRUE(shelf); 128 ASSERT_TRUE(shelf);
89 EXPECT_EQ(shelf->GetChildViewCount(), 0); 129 EXPECT_EQ(shelf->GetChildViewCount(), 0);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 ui_test_utils::ExecuteJavaScriptAndExtractBool( 407 ui_test_utils::ExecuteJavaScriptAndExtractBool(
368 host->render_view_host(), L"", L"testDisconnect()", &result); 408 host->render_view_host(), L"", L"testDisconnect()", &result);
369 EXPECT_TRUE(result); 409 EXPECT_TRUE(result);
370 410
371 // Test disconnect is fired on tab close. 411 // Test disconnect is fired on tab close.
372 result = false; 412 result = false;
373 ui_test_utils::ExecuteJavaScriptAndExtractBool( 413 ui_test_utils::ExecuteJavaScriptAndExtractBool(
374 host->render_view_host(), L"", L"testDisconnectOnClose()", &result); 414 host->render_view_host(), L"", L"testDisconnectOnClose()", &result);
375 EXPECT_TRUE(result); 415 EXPECT_TRUE(result);
376 } 416 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698