Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/info_private_apitest.cc |
| diff --git a/chrome/browser/chromeos/extensions/info_private_apitest.cc b/chrome/browser/chromeos/extensions/info_private_apitest.cc |
| index 6fdb457b1b582debf9cd99eb3e53b3e9e0ea44b4..90054d69074afe51deff5acbc8cecbcaab230f20 100644 |
| --- a/chrome/browser/chromeos/extensions/info_private_apitest.cc |
| +++ b/chrome/browser/chromeos/extensions/info_private_apitest.cc |
| @@ -2,13 +2,56 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/json/json_writer.h" |
| +#include "base/values.h" |
| #include "chrome/browser/chromeos/settings/cros_settings.h" |
| #include "chrome/browser/extensions/extension_apitest.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| +#include "chromeos/chromeos_switches.h" |
| #include "chromeos/settings/cros_settings_names.h" |
| #include "components/prefs/pref_service.h" |
| -IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeOSInfoPrivateTest) { |
| +namespace { |
| + |
| +const char kTestNameKey[] = "testName"; |
| +const char kTestAppId[] = "ljoammodoonkhnehlncldjelhidljdpi"; |
| + |
| +} // namespace |
| + |
| +class ChromeOSInfoPrivateTest : public ExtensionApiTest { |
| + public: |
| + ChromeOSInfoPrivateTest() {} |
| + ~ChromeOSInfoPrivateTest() override {} |
| + |
| + protected: |
| + std::string GenerateTestName(const std::string& test_name) { |
| + base::DictionaryValue test_arg; |
| + std::string result; |
| + test_arg.SetString(kTestNameKey, test_name); |
| + base::JSONWriter::Write(test_arg, &result); |
| + return result; |
| + } |
| + |
| + void EnableKioskSession() { |
| + 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
|
| + switches::kForceAppMode); |
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kAppId, |
| + kTestAppId); |
| + } |
| + |
| + void MakeArcAvailable() { |
| + base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| + chromeos::switches::kArcAvailable); |
| + } |
| + |
| + void EnableArc() { |
| + base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| + chromeos::switches::kEnableArc); |
| + } |
| +}; |
| + |
| +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.
|
| // Set the initial timezone different from what JS function |
| // timezoneSetTest() will attempt to set. |
| base::StringValue initial_timezone("America/Los_Angeles"); |
| @@ -27,7 +70,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeOSInfoPrivateTest) { |
| ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| prefs::kLanguageSendFunctionKeys)); |
| - ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private")) << message_; |
| + ASSERT_TRUE(RunComponentExtensionTest("chromeos_info_private/basic")) |
| + << message_; |
| // Check that all accessibility settings have been flipped by the test. |
| ASSERT_TRUE(prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); |
| @@ -39,3 +83,26 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeOSInfoPrivateTest) { |
| ASSERT_TRUE(prefs->GetBoolean(prefs::kLanguageSendFunctionKeys)); |
| } |
| + |
| +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.
|
| + EnableKioskSession(); |
| + ASSERT_TRUE(RunPlatformAppTestWithArg("chromeos_info_private/extended", |
| + GenerateTestName("kiosk").c_str())) |
| + << message_; |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcAvailable) { |
| + MakeArcAvailable(); |
| + ASSERT_TRUE( |
| + RunPlatformAppTestWithArg("chromeos_info_private/extended", |
| + GenerateTestName("arc available").c_str())) |
| + << message_; |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(ChromeOSInfoPrivateTest, ArcEnabled) { |
| + EnableArc(); |
| + ASSERT_TRUE( |
| + RunPlatformAppTestWithArg("chromeos_info_private/extended", |
| + GenerateTestName("arc enabled").c_str())) |
| + << message_; |
| +} |