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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 11734018: Revert 174880 due to compilation error in pdf_browsertest.cc (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1374/src/
Patch Set: Created 7 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) 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 content::WebContents* contents = chrome::GetActiveWebContents(browser); 230 content::WebContents* contents = chrome::GetActiveWebContents(browser);
231 EXPECT_EQ(url, contents->GetURL()); 231 EXPECT_EQ(url, contents->GetURL());
232 string16 title = UTF8ToUTF16(url.spec() + " is not available"); 232 string16 title = UTF8ToUTF16(url.spec() + " is not available");
233 EXPECT_EQ(title, contents->GetTitle()); 233 EXPECT_EQ(title, contents->GetTitle());
234 234
235 // Verify that the expected error page is being displayed. 235 // Verify that the expected error page is being displayed.
236 // (error 138 == NETWORK_ACCESS_DENIED) 236 // (error 138 == NETWORK_ACCESS_DENIED)
237 bool result = false; 237 bool result = false;
238 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool( 238 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool(
239 contents->GetRenderViewHost(), 239 contents->GetRenderViewHost(),
240 "", 240 std::wstring(),
241 "var hasError = false;" 241 L"var hasError = false;"
242 "var error = document.getElementById('errorDetails');" 242 L"var error = document.getElementById('errorDetails');"
243 "if (error)" 243 L"if (error)"
244 " hasError = error.textContent.indexOf('Error 138') == 0;" 244 L" hasError = error.textContent.indexOf('Error 138') == 0;"
245 "domAutomationController.send(hasError);", 245 L"domAutomationController.send(hasError);",
246 &result)); 246 &result));
247 EXPECT_TRUE(result); 247 EXPECT_TRUE(result);
248 } 248 }
249 249
250 // Downloads a file named |file| and expects it to be saved to |dir|, which 250 // Downloads a file named |file| and expects it to be saved to |dir|, which
251 // must be empty. 251 // must be empty.
252 void DownloadAndVerifyFile( 252 void DownloadAndVerifyFile(
253 Browser* browser, const FilePath& dir, const FilePath& file) { 253 Browser* browser, const FilePath& dir, const FilePath& file) {
254 content::DownloadManager* download_manager = 254 content::DownloadManager* download_manager =
255 content::BrowserContext::GetDownloadManager(browser->profile()); 255 content::BrowserContext::GetDownloadManager(browser->profile());
(...skipping 28 matching lines...) Expand all
284 count++; 284 count++;
285 return count; 285 return count;
286 } 286 }
287 #endif 287 #endif
288 288
289 // Checks if WebGL is enabled in the given WebContents. 289 // Checks if WebGL is enabled in the given WebContents.
290 bool IsWebGLEnabled(content::WebContents* contents) { 290 bool IsWebGLEnabled(content::WebContents* contents) {
291 bool result = false; 291 bool result = false;
292 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool( 292 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool(
293 contents->GetRenderViewHost(), 293 contents->GetRenderViewHost(),
294 "", 294 std::wstring(),
295 "var canvas = document.createElement('canvas');" 295 L"var canvas = document.createElement('canvas');"
296 "var context = canvas.getContext('experimental-webgl');" 296 L"var context = canvas.getContext('experimental-webgl');"
297 "domAutomationController.send(context != null);", 297 L"domAutomationController.send(context != null);",
298 &result)); 298 &result));
299 return result; 299 return result;
300 } 300 }
301 301
302 bool IsJavascriptEnabled(content::WebContents* contents) { 302 bool IsJavascriptEnabled(content::WebContents* contents) {
303 content::RenderViewHost* rvh = contents->GetRenderViewHost(); 303 content::RenderViewHost* rvh = contents->GetRenderViewHost();
304 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( 304 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(
305 string16(), 305 string16(),
306 ASCIIToUTF16("123"))); 306 ASCIIToUTF16("123")));
307 int result = 0; 307 int result = 0;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 455
456 // Wait for feedback page to fully initialize. 456 // Wait for feedback page to fully initialize.
457 // setupCurrentScreenshot is called when feedback page loads and (among 457 // setupCurrentScreenshot is called when feedback page loads and (among
458 // other things) adds current-screenshots-thumbnailDiv-0-image element. 458 // other things) adds current-screenshots-thumbnailDiv-0-image element.
459 // The code below executes either before setupCurrentScreenshot was called 459 // The code below executes either before setupCurrentScreenshot was called
460 // (setupCurrentScreenshot is replaced with our hook) or after it has 460 // (setupCurrentScreenshot is replaced with our hook) or after it has
461 // completed (in that case send result immediately). 461 // completed (in that case send result immediately).
462 bool result = false; 462 bool result = false;
463 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool( 463 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool(
464 web_contents->GetRenderViewHost(), 464 web_contents->GetRenderViewHost(),
465 "", 465 std::wstring(),
466 "function btest_initCompleted(url) {" 466 L"function btest_initCompleted(url) {"
467 " var img = new Image();" 467 L" var img = new Image();"
468 " img.src = url;" 468 L" img.src = url;"
469 " img.onload = function() {" 469 L" img.onload = function() {"
470 " domAutomationController.send(img.width * img.height > 0);" 470 L" domAutomationController.send(img.width * img.height > 0);"
471 " };" 471 L" };"
472 " img.onerror = function() {" 472 L" img.onerror = function() {"
473 " domAutomationController.send(false);" 473 L" domAutomationController.send(false);"
474 " };" 474 L" };"
475 "}" 475 L"}"
476 "function setupCurrentScreenshot(url) {" 476 L"function setupCurrentScreenshot(url) {"
477 " btest_initCompleted(url);" 477 L" btest_initCompleted(url);"
478 "}" 478 L"}"
479 "var img = document.getElementById(" 479 L"var img = document.getElementById("
480 " 'current-screenshots-thumbnailDiv-0-image');" 480 L" 'current-screenshots-thumbnailDiv-0-image');"
481 "if (img)" 481 L"if (img)"
482 " btest_initCompleted(img.src);", 482 L" btest_initCompleted(img.src);",
483 &result)); 483 &result));
484 EXPECT_EQ(enabled, result); 484 EXPECT_EQ(enabled, result);
485 485
486 // Feedback page is a singleton page, so close so future calls to this 486 // Feedback page is a singleton page, so close so future calls to this
487 // function work as expected. 487 // function work as expected.
488 web_contents->Close(); 488 web_contents->Close();
489 } 489 }
490 490
491 #if defined(OS_CHROMEOS) 491 #if defined(OS_CHROMEOS)
492 void TestScreenshotFile(bool enabled) { 492 void TestScreenshotFile(bool enabled) {
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 content::RunAllPendingInMessageLoop(); 1710 content::RunAllPendingInMessageLoop();
1711 1711
1712 GURL kAboutHistograms = GURL(std::string(chrome::kAboutScheme) + 1712 GURL kAboutHistograms = GURL(std::string(chrome::kAboutScheme) +
1713 std::string(content::kStandardSchemeSeparator) + 1713 std::string(content::kStandardSchemeSeparator) +
1714 std::string(chrome::kChromeUIHistogramHost)); 1714 std::string(chrome::kChromeUIHistogramHost));
1715 ui_test_utils::NavigateToURL(browser(), kAboutHistograms); 1715 ui_test_utils::NavigateToURL(browser(), kAboutHistograms);
1716 content::WebContents* contents = chrome::GetActiveWebContents(browser()); 1716 content::WebContents* contents = chrome::GetActiveWebContents(browser());
1717 std::string text; 1717 std::string text;
1718 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( 1718 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
1719 contents->GetRenderViewHost(), 1719 contents->GetRenderViewHost(),
1720 "", 1720 std::wstring(),
1721 "var nodes = document.querySelectorAll('body > pre');" 1721 L"var nodes = document.querySelectorAll('body > pre');"
1722 "var result = '';" 1722 L"var result = '';"
1723 "for (var i = 0; i < nodes.length; ++i) {" 1723 L"for (var i = 0; i < nodes.length; ++i) {"
1724 " var text = nodes[i].innerHTML;" 1724 L" var text = nodes[i].innerHTML;"
1725 " if (text.indexOf('Histogram: Enterprise.Policies') === 0) {" 1725 L" if (text.indexOf('Histogram: Enterprise.Policies') === 0) {"
1726 " result = text;" 1726 L" result = text;"
1727 " break;" 1727 L" break;"
1728 " }" 1728 L" }"
1729 "}" 1729 L"}"
1730 "domAutomationController.send(result);", 1730 L"domAutomationController.send(result);",
1731 &text)); 1731 &text));
1732 ASSERT_FALSE(text.empty()); 1732 ASSERT_FALSE(text.empty());
1733 const std::string kExpectedLabel = 1733 const std::string kExpectedLabel =
1734 "Histogram: Enterprise.Policies recorded 3 samples"; 1734 "Histogram: Enterprise.Policies recorded 3 samples";
1735 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size())); 1735 EXPECT_EQ(kExpectedLabel, text.substr(0, kExpectedLabel.size()));
1736 // HomepageLocation has policy ID 1. 1736 // HomepageLocation has policy ID 1.
1737 EXPECT_NE(std::string::npos, text.find("<br>1 ---")); 1737 EXPECT_NE(std::string::npos, text.find("<br>1 ---"));
1738 // ShowHomeButton has policy ID 35. 1738 // ShowHomeButton has policy ID 35.
1739 EXPECT_NE(std::string::npos, text.find("<br>35 ---")); 1739 EXPECT_NE(std::string::npos, text.find("<br>35 ---"));
1740 // BookmarkBarEnabled has policy ID 82. 1740 // BookmarkBarEnabled has policy ID 82.
1741 EXPECT_NE(std::string::npos, text.find("<br>82 ---")); 1741 EXPECT_NE(std::string::npos, text.find("<br>82 ---"));
1742 } 1742 }
1743 1743
1744 } // namespace policy 1744 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_browsertest.cc ('k') | chrome/browser/policy/policy_prefs_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698