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

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

Issue 150062: [chromium-reviews] Add getLanguage function to tabs extension (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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) 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 25 matching lines...) Expand all
36 host = *iter; 36 host = *iter;
37 } 37 }
38 num_hosts++; 38 num_hosts++;
39 } 39 }
40 EXPECT_EQ(expected_hosts, num_hosts); 40 EXPECT_EQ(expected_hosts, num_hosts);
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 ASSERT_TRUE(LoadExtension( 46 FilePath extension_test_data_dir = test_data_dir_.AppendASCII("good").
47 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 47 AppendASCII("Extensions").AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj").
48 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 48 AppendASCII("1.0.0.0");
49 .AppendASCII("1.0.0.0"))); 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 two ExtensionHosts loaded because this
52 // extension has two toolstrips. Find the one that is hosting toolstrip1.html. 52 // extension has two toolstrips. Find the one that is hosting toolstrip1.html.
53 ExtensionProcessManager* manager = 53 ExtensionProcessManager* manager =
54 browser()->profile()->GetExtensionProcessManager(); 54 browser()->profile()->GetExtensionProcessManager();
55 ExtensionHost* host = FindHostWithPath(manager, "/toolstrip1.html", 2); 55 ExtensionHost* host = FindHostWithPath(manager, "/toolstrip1.html", 2);
56 56
57 // Tell it to run some JavaScript that tests that basic extension code works. 57 // Tell it to run some JavaScript that tests that basic extension code works.
58 bool result = false; 58 bool result = false;
59 ui_test_utils::ExecuteJavaScriptAndExtractBool( 59 ui_test_utils::ExecuteJavaScriptAndExtractBool(
60 host->render_view_host(), L"", L"testTabsAPI()", &result); 60 host->render_view_host(), L"", L"testTabsAPI()", &result);
61 EXPECT_TRUE(result); 61 EXPECT_TRUE(result);
62
63 #if defined(OS_WIN)
64 // 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 // actually call the language detection API through the existing extension,
67 // and verify that the language returned is indeed French.
68 FilePath language_url = extension_test_data_dir.AppendASCII(
69 "french_sentence.html");
70 ui_test_utils::NavigateToURL(
71 browser(),
72 GURL(language_url.ToWStringHack()));
73
74 ui_test_utils::ExecuteJavaScriptAndExtractBool(
75 host->render_view_host(), L"", L"testTabsLanguageAPI()", &result);
76 EXPECT_TRUE(result);
77 #endif
62 } 78 }
63 79
64 // Tests that the ExtensionShelf initializes properly, notices that 80 // Tests that the ExtensionShelf initializes properly, notices that
65 // an extension loaded and has a view available, and then sets that up 81 // an extension loaded and has a view available, and then sets that up
66 // properly. 82 // properly.
67 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Shelf) { 83 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Shelf) {
68 // When initialized, there are no extension views and the preferred height 84 // When initialized, there are no extension views and the preferred height
69 // should be zero. 85 // should be zero.
70 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); 86 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
71 ExtensionShelf* shelf = browser_view->extension_shelf(); 87 ExtensionShelf* shelf = browser_view->extension_shelf();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 ui_test_utils::ExecuteJavaScriptAndExtractBool( 358 ui_test_utils::ExecuteJavaScriptAndExtractBool(
343 host->render_view_host(), L"", L"testPostMessage()", &result); 359 host->render_view_host(), L"", L"testPostMessage()", &result);
344 EXPECT_TRUE(result); 360 EXPECT_TRUE(result);
345 361
346 result = false; 362 result = false;
347 ui_test_utils::ExecuteJavaScriptAndExtractBool( 363 ui_test_utils::ExecuteJavaScriptAndExtractBool(
348 host->render_view_host(), L"", L"testDisconnectOnClose()", &result); 364 host->render_view_host(), L"", L"testDisconnectOnClose()", &result);
349 EXPECT_TRUE(result); 365 EXPECT_TRUE(result);
350 } 366 }
351 #endif 367 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698