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

Side by Side Diff: chrome/browser/ui/webui/options/preferences_browsertest.cc

Issue 2907493002: ChromeOS: Per-user time zone: refactor tests first. (Closed)
Patch Set: Update after review. Created 3 years, 7 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
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 "chrome/browser/ui/webui/options/preferences_browsertest.h" 5 #include "chrome/browser/ui/webui/options/preferences_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <iostream> 9 #include <iostream>
10 #include <memory> 10 #include <memory>
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 // List pref. 689 // List pref.
690 pref_names_.push_back(chromeos::kAccountsPrefUsers); 690 pref_names_.push_back(chromeos::kAccountsPrefUsers);
691 default_values_.push_back(base::MakeUnique<base::ListValue>()); 691 default_values_.push_back(base::MakeUnique<base::ListValue>());
692 692
693 // Verify notifications when default values are in effect. 693 // Verify notifications when default values are in effect.
694 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 694 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
695 VerifyObservedPrefs(observed_json, pref_names_, default_values_, "owner", 695 VerifyObservedPrefs(observed_json, pref_names_, default_values_, "owner",
696 true, false); 696 true, false);
697 } 697 }
698 698
699 // Verifies that initializing the JavaScript Preferences class fires the correct
xiyuan 2017/05/26 17:14:53 Does this belong to this CL?
Alexander Alekseev 2017/05/26 18:06:21 Done.
700 // notifications in JavaScript for non-privileged pref values handled by the
701 // CoreChromeOSOptionsHandler class.
702 IN_PROC_BROWSER_TEST_F(PreferencesBrowserTest,
703 ChromeOSDeviceFetchNonPrivilegedPrefs) {
704 std::vector<std::unique_ptr<base::Value>> decorated_non_default_values;
705 std::string observed_json;
706
707 // Non-privileged string pref.
708 pref_names_.push_back(chromeos::kSystemTimezone);
709 default_values_.push_back(
710 base::MakeUnique<base::Value>("America/Los_Angeles"));
711 non_default_values_.push_back(
712 base::MakeUnique<base::Value>("America/New_York"));
713 decorated_non_default_values.push_back(
714 non_default_values_.back()->CreateDeepCopy());
715
716 // Verify notifications when default values are in effect.
717 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
718 VerifyObservedPrefs(observed_json, pref_names_, default_values_,
719 std::string(), false, false);
720
721 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get();
722 cros_settings->Set(pref_names_[0], *non_default_values_[0]);
723
724 // Verify notifications when non-default values are in effect.
725 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
726 VerifyObservedPrefs(observed_json, pref_names_, decorated_non_default_values,
727 std::string(), false, false);
728 }
729
730 class ManagedPreferencesBrowserTest : public PreferencesBrowserTest { 699 class ManagedPreferencesBrowserTest : public PreferencesBrowserTest {
731 protected: 700 protected:
732 // PreferencesBrowserTest implementation: 701 // PreferencesBrowserTest implementation:
733 void SetUpInProcessBrowserTestFixture() override { 702 void SetUpInProcessBrowserTestFixture() override {
734 // Set up fake install attributes. 703 // Set up fake install attributes.
735 std::unique_ptr<chromeos::StubInstallAttributes> attributes = 704 std::unique_ptr<chromeos::StubInstallAttributes> attributes =
736 base::MakeUnique<chromeos::StubInstallAttributes>(); 705 base::MakeUnique<chromeos::StubInstallAttributes>();
737 attributes->SetCloudManaged("example.com", "fake-id"); 706 attributes->SetCloudManaged("example.com", "fake-id");
738 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( 707 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting(
739 attributes.release()); 708 attributes.release());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 for (size_t i = 0; i < pref_names_.size(); ++i) { 757 for (size_t i = 0; i < pref_names_.size(); ++i) {
789 cros_settings->Set(pref_names_[i], *non_default_values_[i]); 758 cros_settings->Set(pref_names_[i], *non_default_values_[i]);
790 } 759 }
791 760
792 // Verify notifications when mandatory values are in effect. 761 // Verify notifications when mandatory values are in effect.
793 SetupJavaScriptTestEnvironment(pref_names_, &observed_json); 762 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
794 VerifyObservedPrefs(observed_json, pref_names_, decorated_non_default_values, 763 VerifyObservedPrefs(observed_json, pref_names_, decorated_non_default_values,
795 "policy", true, false); 764 "policy", true, false);
796 } 765 }
797 766
798 // Verifies that initializing the JavaScript Preferences class fires the correct
799 // notifications in JavaScript for non-privileged pref values handled by the
800 // CoreChromeOSOptionsHandler class for a managed device.
801 IN_PROC_BROWSER_TEST_F(ManagedPreferencesBrowserTest,
802 ChromeOSDeviceFetchNonPrivilegedPrefs) {
803 std::vector<std::unique_ptr<base::Value>> decorated_non_default_values;
804 std::string observed_json;
805
806 // Non-privileged string pref.
807 pref_names_.push_back(chromeos::kSystemTimezone);
808 non_default_values_.push_back(
809 base::MakeUnique<base::Value>("America/New_York"));
810 decorated_non_default_values.push_back(
811 non_default_values_.back()->CreateDeepCopy());
812
813 // Verify notifications when mandatory values are in effect.
814 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get();
815 cros_settings->Set(pref_names_[0], *non_default_values_[0]);
816
817 SetupJavaScriptTestEnvironment(pref_names_, &observed_json);
818 VerifyObservedPrefs(observed_json, pref_names_, decorated_non_default_values,
819 std::string(), false, false);
820 }
821
822 namespace { 767 namespace {
823 768
824 const char* kUserProfilePath = "user_profile"; 769 const char* kUserProfilePath = "user_profile";
825 770
826 } // namespace 771 } // namespace
827 772
828 class ProxyPreferencesBrowserTest : public PreferencesBrowserTest { 773 class ProxyPreferencesBrowserTest : public PreferencesBrowserTest {
829 public: 774 public:
830 void SetUpOnMainThread() override { 775 void SetUpOnMainThread() override {
831 SetupNetworkEnvironment(); 776 SetupNetworkEnvironment();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 base::Value(3)); 1042 base::Value(3));
1098 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocksPort, 1043 SetProxyPref(chromeos::proxy_cros_settings_parser::kProxySocksPort,
1099 base::Value(4)); 1044 base::Value(4));
1100 1045
1101 VerifyCurrentProxyServer( 1046 VerifyCurrentProxyServer(
1102 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4", 1047 "http=a.com:1;https=4.3.2.1:2;ftp=c.com:3;socks=socks4://d.com:4",
1103 onc::ONC_SOURCE_NONE); 1048 onc::ONC_SOURCE_NONE);
1104 } 1049 }
1105 1050
1106 #endif 1051 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698