OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" | 8 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/browser/signin/easy_unlock_service.h" | 12 #include "chrome/browser/signin/easy_unlock_service.h" |
13 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
14 #include "components/signin/core/browser/signin_manager.h" | 14 #include "components/signin/core/browser/signin_manager.h" |
15 #include "components/signin/core/common/profile_management_switches.h" | 15 #include "components/signin/core/common/profile_management_switches.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "extensions/browser/api/test/test_api.h" | 17 #include "extensions/browser/api/test/test_api.h" |
18 #include "extensions/browser/notification_types.h" | 18 #include "extensions/browser/notification_types.h" |
19 #include "extensions/common/switches.h" | 19 #include "extensions/common/switches.h" |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
| 25 const char kTestGaiaId[] = "gaia-id-testuser@gmail.com"; |
25 const char kAttemptClickAuthMessage[] = "attemptClickAuth"; | 26 const char kAttemptClickAuthMessage[] = "attemptClickAuth"; |
26 const char kTestExtensionId[] = "lkegkdgachcnekllcdfkijonogckdnjo"; | 27 const char kTestExtensionId[] = "lkegkdgachcnekllcdfkijonogckdnjo"; |
27 const char kTestUser[] = "testuser@gmail.com"; | 28 const char kTestUser[] = "testuser@gmail.com"; |
28 | 29 |
29 } // namespace | 30 } // namespace |
30 | 31 |
31 class ScreenlockPrivateApiTest : public ExtensionApiTest, | 32 class ScreenlockPrivateApiTest : public ExtensionApiTest, |
32 public content::NotificationObserver { | 33 public content::NotificationObserver { |
33 public: | 34 public: |
34 ScreenlockPrivateApiTest() {} | 35 ScreenlockPrivateApiTest() {} |
35 | 36 |
36 ~ScreenlockPrivateApiTest() override {} | 37 ~ScreenlockPrivateApiTest() override {} |
37 | 38 |
38 // ExtensionApiTest | 39 // ExtensionApiTest |
39 void SetUpCommandLine(base::CommandLine* command_line) override { | 40 void SetUpCommandLine(base::CommandLine* command_line) override { |
40 ExtensionApiTest::SetUpCommandLine(command_line); | 41 ExtensionApiTest::SetUpCommandLine(command_line); |
41 command_line->AppendSwitchASCII( | 42 command_line->AppendSwitchASCII( |
42 extensions::switches::kWhitelistedExtensionID, kTestExtensionId); | 43 extensions::switches::kWhitelistedExtensionID, kTestExtensionId); |
43 | 44 |
44 #if !defined(OS_CHROMEOS) | 45 #if !defined(OS_CHROMEOS) |
45 // New profile management needs to be on for non-ChromeOS lock. | 46 // New profile management needs to be on for non-ChromeOS lock. |
46 ::switches::EnableNewProfileManagementForTesting(command_line); | 47 ::switches::EnableNewProfileManagementForTesting(command_line); |
47 #endif | 48 #endif |
48 } | 49 } |
49 | 50 |
50 void SetUpOnMainThread() override { | 51 void SetUpOnMainThread() override { |
51 SigninManagerFactory::GetForProfile(profile()) | 52 SigninManagerFactory::GetForProfile(profile()) |
52 ->SetAuthenticatedUsername(kTestUser); | 53 ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser); |
53 ProfileInfoCache& info_cache = | 54 ProfileInfoCache& info_cache = |
54 g_browser_process->profile_manager()->GetProfileInfoCache(); | 55 g_browser_process->profile_manager()->GetProfileInfoCache(); |
55 size_t index = info_cache.GetIndexOfProfileWithPath(profile()->GetPath()); | 56 size_t index = info_cache.GetIndexOfProfileWithPath(profile()->GetPath()); |
56 ASSERT_NE(std::string::npos, index); | 57 ASSERT_NE(std::string::npos, index); |
57 info_cache.SetUserNameOfProfileAtIndex(index, base::UTF8ToUTF16(kTestUser)); | 58 info_cache.SetUserNameOfProfileAtIndex(index, base::UTF8ToUTF16(kTestUser)); |
58 ExtensionApiTest::SetUpOnMainThread(); | 59 ExtensionApiTest::SetUpOnMainThread(); |
59 } | 60 } |
60 | 61 |
61 protected: | 62 protected: |
62 // ExtensionApiTest override: | 63 // ExtensionApiTest override: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 96 |
96 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, LockUnlock) { | 97 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, LockUnlock) { |
97 RunTest("screenlock_private/lock_unlock"); | 98 RunTest("screenlock_private/lock_unlock"); |
98 } | 99 } |
99 | 100 |
100 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, AuthType) { | 101 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, AuthType) { |
101 RunTest("screenlock_private/auth_type"); | 102 RunTest("screenlock_private/auth_type"); |
102 } | 103 } |
103 | 104 |
104 } // namespace extensions | 105 } // namespace extensions |
OLD | NEW |