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

Side by Side Diff: chrome/browser/chromeos/extensions/info_private_apitest.cc

Issue 2314313002: Add sessionType and playStoreStatus to chromeosInfoPrivate. (Closed)
Patch Set: review comments Created 4 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/json/json_writer.h"
6 #include "base/values.h"
5 #include "chrome/browser/chromeos/settings/cros_settings.h" 7 #include "chrome/browser/chromeos/settings/cros_settings.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/common/chrome_switches.h"
7 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chromeos/chromeos_switches.h"
8 #include "chromeos/settings/cros_settings_names.h" 12 #include "chromeos/settings/cros_settings_names.h"
9 #include "components/prefs/pref_service.h" 13 #include "components/prefs/pref_service.h"
10 14
11 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeOSInfoPrivateTest) { 15 namespace {
16
17 const char kTestNameKey[] = "testName";
18 const char kTestAppId[] = "ljoammodoonkhnehlncldjelhidljdpi";
19
20 } // namespace
21
22 class ChromeOSInfoPrivateTest : public ExtensionApiTest {
23 public:
24 ChromeOSInfoPrivateTest() {}
25 ~ChromeOSInfoPrivateTest() override {}
26
27 protected:
28 std::string GenerateTestName(const std::string& test_name) {
29 base::DictionaryValue test_arg;
30 std::string result;
31 test_arg.SetString(kTestNameKey, test_name);
32 base::JSONWriter::Write(test_arg, &result);
33 return result;
34 }
35
36 void EnableKioskSession() {
37 base::CommandLine::ForCurrentProcess()->AppendSwitch(
Devlin 2016/09/07 16:12:28 Does it matter that we're appending all these swit
Rahul Chaturvedi 2016/09/07 20:13:23 Nope. These aren't checked at startup, they are ch
38 switches::kForceAppMode);
39 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId,
40 kTestAppId);
41 }
42
43 void MakeArcAvailable() {
44 base::CommandLine::ForCurrentProcess()->AppendSwitch(
45 chromeos::switches::kArcAvailable);
46 }
47
48 void EnableArc() {
49 base::CommandLine::ForCurrentProcess()->AppendSwitch(
50 chromeos::switches::kEnableArc);
51 }
52 };
53
54 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Basic) {
Devlin 2016/09/07 16:12:28 "Basic" doesn't really describe what this tests.
Rahul Chaturvedi 2016/09/07 20:13:23 It is better than "ChromeOSInfoPrivateTest", which
Devlin 2016/09/07 20:40:29 Looks like we just test get() and set() in that te
Rahul Chaturvedi 2016/09/07 20:45:01 Done.
12 // Set the initial timezone different from what JS function 55 // Set the initial timezone different from what JS function
13 // timezoneSetTest() will attempt to set. 56 // timezoneSetTest() will attempt to set.
14 base::StringValue initial_timezone("America/Los_Angeles"); 57 base::StringValue initial_timezone("America/Los_Angeles");
15 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, 58 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone,
16 initial_timezone); 59 initial_timezone);
17 60
18 // Check that accessibility settings are set to default values. 61 // Check that accessibility settings are set to default values.
19 PrefService* prefs = profile()->GetPrefs(); 62 PrefService* prefs = profile()->GetPrefs();
20 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); 63 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled));
21 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); 64 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled));
22 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); 65 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled));
23 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); 66 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled));
24 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); 67 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled));
25 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); 68 ASSERT_FALSE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled));
26 69
27 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( 70 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean(
28 prefs::kLanguageSendFunctionKeys)); 71 prefs::kLanguageSendFunctionKeys));
29 72
30 ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private")) << message_; 73 ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private/basic"))
74 << message_;
31 75
32 // Check that all accessibility settings have been flipped by the test. 76 // Check that all accessibility settings have been flipped by the test.
33 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); 77 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled));
34 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled)); 78 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityStickyKeysEnabled));
35 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled)); 79 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled));
36 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled)); 80 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityHighContrastEnabled));
37 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)); 81 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled));
38 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled)); 82 ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityAutoclickEnabled));
39 83
40 ASSERT_TRUE(prefs->GetBoolean(prefs::kLanguageSendFunctionKeys)); 84 ASSERT_TRUE(prefs->GetBoolean(prefs::kLanguageSendFunctionKeys));
41 } 85 }
86
87 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, Kiosk) {
Devlin 2016/09/07 16:12:28 What about public session?
Devlin 2016/09/07 16:12:28 Browser tests are pretty slow. If we can adjust t
Rahul Chaturvedi 2016/09/07 20:13:23 I have no good way to test that now. I will add te
Rahul Chaturvedi 2016/09/07 20:13:23 Calling RunPlatformAppTestWithArg multiple times o
Devlin 2016/09/07 20:23:27 That's because RunPlatformAppTest loads the extens
Devlin 2016/09/07 20:38:50 As discussed offline, we can leave this as-is for
Rahul Chaturvedi 2016/09/07 20:45:01 Done.
88 EnableKioskSession();
89 ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended",
90 GenerateTestName("kiosk").c_str()))
91 << message_;
92 }
93
94 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcAvailable) {
95 MakeArcAvailable();
96 ASSERT_TRUE(
97 RunPlatformAppTestWithArg("chromeos_info_private/extended",
98 GenerateTestName("arc available").c_str()))
99 << message_;
100 }
101
102 IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcEnabled) {
103 EnableArc();
104 ASSERT_TRUE(
105 RunPlatformAppTestWithArg("chromeos_info_private/extended",
106 GenerateTestName("arc enabled").c_str()))
107 << message_;
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698