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

Side by Side Diff: chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc

Issue 289013002: cros: Clean up screenlockPrivate plumbing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove "multiple-signin-banner-text" Created 6 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/chrome_notification_types.h" 5 #include "chrome/browser/chrome_notification_types.h"
6 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 6 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h"
7 #include "chrome/browser/chromeos/login/users/user.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/signin/signin_manager_factory.h" 8 #include "chrome/browser/signin/signin_manager_factory.h"
10 #include "components/signin/core/browser/signin_manager.h" 9 #include "components/signin/core/browser/signin_manager.h"
10 #include "components/signin/core/common/signin_switches.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 #include "extensions/browser/api/test/test_api.h" 12 #include "extensions/browser/api/test/test_api.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 namespace { 16 namespace {
17 17
18 const char kTestUser[] = "testuser@gmail.com";
18 const char kAttemptClickAuthMessage[] = "attemptClickAuth"; 19 const char kAttemptClickAuthMessage[] = "attemptClickAuth";
19 20
20 } // namespace 21 } // namespace
21 22
22 class ScreenlockPrivateApiTest : public ExtensionApiTest, 23 class ScreenlockPrivateApiTest : public ExtensionApiTest,
23 public content::NotificationObserver { 24 public content::NotificationObserver {
24 public: 25 public:
25 ScreenlockPrivateApiTest() {} 26 ScreenlockPrivateApiTest() {}
26 27
27 virtual ~ScreenlockPrivateApiTest() {} 28 virtual ~ScreenlockPrivateApiTest() {}
28 29
29 // ExtensionApiTest 30 // ExtensionApiTest
31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
32 ExtensionApiTest::SetUpCommandLine(command_line);
33
34 #if !defined(OS_CHROMEOS)
35 // New profile managerment needs to be on for non-ChromeOS lock.
asargent_no_longer_on_chrome 2014/05/19 17:53:47 typo: managerment -> management
xiyuan 2014/05/19 17:57:21 Done.
36 command_line->AppendSwitch(switches::kNewProfileManagement);
37 #endif
38 }
39
30 virtual void SetUpOnMainThread() OVERRIDE { 40 virtual void SetUpOnMainThread() OVERRIDE {
31 SigninManagerFactory::GetForProfile(profile()) 41 SigninManagerFactory::GetForProfile(profile())
32 ->SetAuthenticatedUsername("testuser@gmail.com"); 42 ->SetAuthenticatedUsername(kTestUser);
33 ExtensionApiTest::SetUpOnMainThread(); 43 ExtensionApiTest::SetUpOnMainThread();
34 } 44 }
35 45
36 protected: 46 protected:
37 chromeos::ScreenLocker* GetScreenLocker() {
38 chromeos::ScreenLocker* locker =
39 chromeos::ScreenLocker::default_screen_locker();
40 EXPECT_TRUE(locker);
41 return locker;
42 }
43
44 // ExtensionApiTest override: 47 // ExtensionApiTest override:
45 virtual void RunTestOnMainThreadLoop() OVERRIDE { 48 virtual void RunTestOnMainThreadLoop() OVERRIDE {
46 registrar_.Add(this, 49 registrar_.Add(this,
47 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, 50 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE,
48 content::NotificationService::AllSources()); 51 content::NotificationService::AllSources());
49 ExtensionApiTest::RunTestOnMainThreadLoop(); 52 ExtensionApiTest::RunTestOnMainThreadLoop();
50 registrar_.RemoveAll(); 53 registrar_.RemoveAll();
51 } 54 }
52 55
53 // content::NotificationObserver override: 56 // content::NotificationObserver override:
54 virtual void Observe(int type, 57 virtual void Observe(int type,
55 const content::NotificationSource& source, 58 const content::NotificationSource& source,
56 const content::NotificationDetails& details) OVERRIDE { 59 const content::NotificationDetails& details) OVERRIDE {
57 const std::string& content = *content::Details<std::string>(details).ptr(); 60 const std::string& content = *content::Details<std::string>(details).ptr();
58 if (content == kAttemptClickAuthMessage) { 61 if (content == kAttemptClickAuthMessage) {
59 chromeos::ScreenLocker* locker = GetScreenLocker(); 62 extensions::ScreenlockPrivateEventRouter* router =
60 const chromeos::UserList& users = locker->users(); 63 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
61 EXPECT_GE(1u, users.size()); 64 profile());
62 GetScreenLocker()->Authenticate(chromeos::UserContext(users[0]->email())); 65 router->OnAuthAttempted(
66 ScreenlockBridge::Get()->lock_handler()->GetAuthType(kTestUser), "");
63 } 67 }
64 } 68 }
65 69
70 private:
66 content::NotificationRegistrar registrar_; 71 content::NotificationRegistrar registrar_;
72
73 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateApiTest);
67 }; 74 };
68 75
69 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, LockUnlock) { 76 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, LockUnlock) {
70 ASSERT_TRUE(RunExtensionTest("screenlock_private/lock_unlock")) << message_; 77 ASSERT_TRUE(RunExtensionTest("screenlock_private/lock_unlock")) << message_;
71 } 78 }
72 79
73 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, AuthType) { 80 IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, AuthType) {
74 ASSERT_TRUE(RunExtensionTest("screenlock_private/auth_type")) << message_; 81 ASSERT_TRUE(RunExtensionTest("screenlock_private/auth_type")) << message_;
75 } 82 }
76 83
77 } // namespace extensions 84 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698