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

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

Issue 11753009: Simplify ExecuteJavaScript* functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update prerender_browsertest.cc. 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 <map> 6 #include <map>
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 << " indicator.readOnly = node.readOnly || false;" 324 << " indicator.readOnly = node.readOnly || false;"
325 << " indicator.visible =" 325 << " indicator.visible ="
326 << " window.getComputedStyle(node).display != 'none';" 326 << " window.getComputedStyle(node).display != 'none';"
327 << " indicators.push(indicator)" 327 << " indicators.push(indicator)"
328 << "}" 328 << "}"
329 << "domAutomationController.send(JSON.stringify(indicators));"; 329 << "domAutomationController.send(JSON.stringify(indicators));";
330 content::WebContents* contents = chrome::GetActiveWebContents(browser); 330 content::WebContents* contents = chrome::GetActiveWebContents(browser);
331 std::string json; 331 std::string json;
332 // Retrieve the state of all controlled setting indicators matching the 332 // Retrieve the state of all controlled setting indicators matching the
333 // |selector| as JSON. 333 // |selector| as JSON.
334 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( 334 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, javascript.str(),
335 contents->GetRenderViewHost(), "", javascript.str(), &json)); 335 &json));
336 scoped_ptr<base::Value> value_ptr(base::JSONReader::Read(json)); 336 scoped_ptr<base::Value> value_ptr(base::JSONReader::Read(json));
337 const base::ListValue* indicators = NULL; 337 const base::ListValue* indicators = NULL;
338 ASSERT_TRUE(value_ptr.get()); 338 ASSERT_TRUE(value_ptr.get());
339 ASSERT_TRUE(value_ptr->GetAsList(&indicators)); 339 ASSERT_TRUE(value_ptr->GetAsList(&indicators));
340 // Verify that controlled setting indicators representing |value| are visible 340 // Verify that controlled setting indicators representing |value| are visible
341 // and have the correct state while those not representing |value| are 341 // and have the correct state while those not representing |value| are
342 // invisible. 342 // invisible.
343 if (!controlled_by.empty()) { 343 if (!controlled_by.empty()) {
344 EXPECT_GT(indicators->GetSize(), 0u) 344 EXPECT_GT(indicators->GetSize(), 0u)
345 << "Expected to find at least one controlled setting indicator."; 345 << "Expected to find at least one controlled setting indicator.";
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 pref_mapping = pref_mappings.begin(); 484 pref_mapping = pref_mappings.begin();
485 pref_mapping != pref_mappings.end(); 485 pref_mapping != pref_mappings.end();
486 ++pref_mapping) { 486 ++pref_mapping) {
487 const ScopedVector<IndicatorTestCase>& 487 const ScopedVector<IndicatorTestCase>&
488 indicator_test_cases = (*pref_mapping)->indicator_test_cases(); 488 indicator_test_cases = (*pref_mapping)->indicator_test_cases();
489 if (indicator_test_cases.empty()) 489 if (indicator_test_cases.empty())
490 continue; 490 continue;
491 491
492 ui_test_utils::NavigateToURL(browser(), GURL(kMainSettingsPage)); 492 ui_test_utils::NavigateToURL(browser(), GURL(kMainSettingsPage));
493 if (!(*pref_mapping)->indicator_test_setup_js().empty()) { 493 if (!(*pref_mapping)->indicator_test_setup_js().empty()) {
494 ASSERT_TRUE(content::ExecuteJavaScript( 494 ASSERT_TRUE(content::ExecuteScript(
495 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 495 chrome::GetActiveWebContents(browser()),
496 "",
497 (*pref_mapping)->indicator_test_setup_js())); 496 (*pref_mapping)->indicator_test_setup_js()));
498 } 497 }
499 498
500 std::string indicator_selector = (*pref_mapping)->indicator_selector(); 499 std::string indicator_selector = (*pref_mapping)->indicator_selector();
501 if (indicator_selector.empty()) 500 if (indicator_selector.empty())
502 indicator_selector = "[pref=\"" + (*pref_mapping)->pref() + "\"]"; 501 indicator_selector = "[pref=\"" + (*pref_mapping)->pref() + "\"]";
503 for (ScopedVector<IndicatorTestCase>::const_iterator 502 for (ScopedVector<IndicatorTestCase>::const_iterator
504 indicator_test_case = indicator_test_cases.begin(); 503 indicator_test_case = indicator_test_cases.begin();
505 indicator_test_case != indicator_test_cases.end(); 504 indicator_test_case != indicator_test_cases.end();
506 ++indicator_test_case) { 505 ++indicator_test_case) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 554 }
556 } 555 }
557 556
558 INSTANTIATE_TEST_CASE_P( 557 INSTANTIATE_TEST_CASE_P(
559 PolicyPrefsTestInstance, 558 PolicyPrefsTestInstance,
560 PolicyPrefsTest, 559 PolicyPrefsTest,
561 testing::ValuesIn(GetChromePolicyDefinitionList()->begin, 560 testing::ValuesIn(GetChromePolicyDefinitionList()->begin,
562 GetChromePolicyDefinitionList()->end)); 561 GetChromePolicyDefinitionList()->end));
563 562
564 } // namespace policy 563 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/popup_blocker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698