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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #endif | 49 #endif |
50 } | 50 } |
51 | 51 |
52 void SetUpOnMainThread() override { | 52 void SetUpOnMainThread() override { |
53 SigninManagerFactory::GetForProfile(profile()) | 53 SigninManagerFactory::GetForProfile(profile()) |
54 ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser); | 54 ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser); |
55 ProfileInfoCache& info_cache = | 55 ProfileInfoCache& info_cache = |
56 g_browser_process->profile_manager()->GetProfileInfoCache(); | 56 g_browser_process->profile_manager()->GetProfileInfoCache(); |
57 size_t index = info_cache.GetIndexOfProfileWithPath(profile()->GetPath()); | 57 size_t index = info_cache.GetIndexOfProfileWithPath(profile()->GetPath()); |
58 ASSERT_NE(std::string::npos, index); | 58 ASSERT_NE(std::string::npos, index); |
59 info_cache.SetAuthInfoOfProfileAtIndex(index, kTestGaiaId, | 59 info_cache.SetAuthInfoOfProfileAtIndex( |
60 base::UTF8ToUTF16(kTestUser)); | 60 index, kTestGaiaId, base::UTF8ToUTF16(test_account_id_.GetUserEmail())); |
61 ExtensionApiTest::SetUpOnMainThread(); | 61 ExtensionApiTest::SetUpOnMainThread(); |
62 } | 62 } |
63 | 63 |
64 protected: | 64 protected: |
65 // ExtensionApiTest override: | 65 // ExtensionApiTest override: |
66 void RunTestOnMainThreadLoop() override { | 66 void RunTestOnMainThreadLoop() override { |
67 registrar_.Add(this, | 67 registrar_.Add(this, |
68 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, | 68 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, |
69 content::NotificationService::AllSources()); | 69 content::NotificationService::AllSources()); |
70 ExtensionApiTest::RunTestOnMainThreadLoop(); | 70 ExtensionApiTest::RunTestOnMainThreadLoop(); |
71 registrar_.RemoveAll(); | 71 registrar_.RemoveAll(); |
72 } | 72 } |
73 | 73 |
74 // content::NotificationObserver override: | 74 // content::NotificationObserver override: |
75 void Observe(int type, | 75 void Observe(int type, |
76 const content::NotificationSource& source, | 76 const content::NotificationSource& source, |
77 const content::NotificationDetails& details) override { | 77 const content::NotificationDetails& details) override { |
78 const std::string& content = *content::Details<std::string>(details).ptr(); | 78 const std::string& content = *content::Details<std::string>(details).ptr(); |
79 if (content == kAttemptClickAuthMessage) { | 79 if (content == kAttemptClickAuthMessage) { |
80 proximity_auth::ScreenlockBridge::Get()->lock_handler()->SetAuthType( | 80 proximity_auth::ScreenlockBridge::Get()->lock_handler()->SetAuthType( |
81 kTestUser, proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK, | 81 test_account_id_, |
| 82 proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK, |
82 base::string16()); | 83 base::string16()); |
83 EasyUnlockService::Get(profile())->AttemptAuth(kTestUser); | 84 EasyUnlockService::Get(profile())->AttemptAuth(test_account_id_); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 // Loads |extension_name| and waits for a pass / fail notification. | 88 // Loads |extension_name| and waits for a pass / fail notification. |
88 void RunTest(const std::string& extension_name) { | 89 void RunTest(const std::string& extension_name) { |
89 ASSERT_TRUE(RunComponentExtensionTest(extension_name)) << message_; | 90 ASSERT_TRUE(RunComponentExtensionTest(extension_name)) << message_; |
90 } | 91 } |
91 | 92 |
92 private: | 93 private: |
| 94 const AccountId test_account_id_ = |
| 95 AccountId::FromUserEmailGaiaId(kTestUser, kTestGaiaId); |
93 content::NotificationRegistrar registrar_; | 96 content::NotificationRegistrar registrar_; |
94 | 97 |
95 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateApiTest); | 98 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateApiTest); |
96 }; | 99 }; |
97 | 100 |
98 // Locking is currently implemented only on ChromeOS. | 101 // Locking is currently implemented only on ChromeOS. |
99 #if defined(OS_CHROMEOS) | 102 #if defined(OS_CHROMEOS) |
100 | 103 |
101 // Flaky under MSan. http://crbug.com/478091 | 104 // Flaky under MSan. http://crbug.com/478091 |
102 #if defined(MEMORY_SANITIZER) | 105 #if defined(MEMORY_SANITIZER) |
103 #define MAYBE_LockUnlock DISABLED_LockUnlock | 106 #define MAYBE_LockUnlock DISABLED_LockUnlock |
104 #else | 107 #else |
105 #define MAYBE_LockUnlock LockUnlock | 108 #define MAYBE_LockUnlock LockUnlock |
106 #endif | 109 #endif |
107 | 110 |
108 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, MAYBE_LockUnlock) { | 111 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, MAYBE_LockUnlock) { |
109 RunTest("screenlock_private/lock_unlock"); | 112 RunTest("screenlock_private/lock_unlock"); |
110 } | 113 } |
111 | 114 |
112 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, AuthType) { | 115 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, AuthType) { |
113 RunTest("screenlock_private/auth_type"); | 116 RunTest("screenlock_private/auth_type"); |
114 } | 117 } |
115 | 118 |
116 #endif // defined(OS_CHROMEOS) | 119 #endif // defined(OS_CHROMEOS) |
117 | 120 |
118 } // namespace extensions | 121 } // namespace extensions |
OLD | NEW |