| 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 "chrome/browser/net/nss_context.h" | 5 #include "chrome/browser/net/nss_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/chromeos/login/login_manager_test.h" | 9 #include "chrome/browser/chromeos/login/login_manager_test_helper.h" |
| 10 #include "chrome/browser/chromeos/login/startup_utils.h" | 10 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 11 #include "chrome/browser/chromeos/login/user.h" | 11 #include "chrome/browser/chromeos/login/user.h" |
| 12 #include "chrome/browser/chromeos/login/user_adding_screen.h" | 12 #include "chrome/browser/chromeos/login/user_adding_screen.h" |
| 13 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "net/cert/nss_cert_database.h" | 16 #include "net/cert/nss_cert_database.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const char kTestUser1[] = "test-user1@gmail.com"; | 20 const char kTestUser1[] = "test-user1@gmail.com"; |
| 20 const char kTestUser2[] = "test-user2@gmail.com"; | 21 const char kTestUser2[] = "test-user2@gmail.com"; |
| 21 | 22 |
| 22 void NotCalledDbCallback(net::NSSCertDatabase* db) { ASSERT_TRUE(false); } | 23 void NotCalledDbCallback(net::NSSCertDatabase* db) { ASSERT_TRUE(false); } |
| 23 | 24 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 content::BrowserThread::PostTask( | 109 content::BrowserThread::PostTask( |
| 109 content::BrowserThread::UI, FROM_HERE, done_callback); | 110 content::BrowserThread::UI, FROM_HERE, done_callback); |
| 110 } | 111 } |
| 111 | 112 |
| 112 Profile* profile_; | 113 Profile* profile_; |
| 113 net::NSSCertDatabase* db_; | 114 net::NSSCertDatabase* db_; |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 } // namespace | 117 } // namespace |
| 117 | 118 |
| 118 class NSSContextChromeOSBrowserTest : public chromeos::LoginManagerTest { | 119 class NSSContextChromeOSBrowserTest : public InProcessBrowserTest { |
| 119 public: | 120 public: |
| 120 NSSContextChromeOSBrowserTest() | 121 NSSContextChromeOSBrowserTest() |
| 121 : LoginManagerTest(true /* should_launch_browser */) {} | 122 : login_manager_test_helper_(new chromeos::LoginManagerTestHelper) { |
| 123 set_exit_when_last_browser_closes(false); |
| 124 } |
| 125 |
| 122 virtual ~NSSContextChromeOSBrowserTest() {} | 126 virtual ~NSSContextChromeOSBrowserTest() {} |
| 127 |
| 128 virtual void SetUpOnMainThread() OVERRIDE { |
| 129 login_manager_test_helper_->SetUp(); |
| 130 } |
| 131 |
| 132 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 133 login_manager_test_helper_->SetUpCommandLine(command_line); |
| 134 } |
| 135 |
| 136 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 137 login_manager_test_helper_->SetUpLoginUtils(true); |
| 138 } |
| 139 |
| 140 virtual void CleanUpOnMainThread() OVERRIDE { |
| 141 login_manager_test_helper_->CleanUp(); |
| 142 } |
| 143 |
| 144 protected: |
| 145 scoped_ptr<chromeos::LoginManagerTestHelper> login_manager_test_helper_; |
| 123 }; | 146 }; |
| 124 | 147 |
| 125 IN_PROC_BROWSER_TEST_F(NSSContextChromeOSBrowserTest, PRE_TwoUsers) { | 148 IN_PROC_BROWSER_TEST_F(NSSContextChromeOSBrowserTest, PRE_TwoUsers) { |
| 126 // Initialization for ChromeOS multi-profile test infrastructure. | 149 // Initialization for ChromeOS multi-profile test infrastructure. |
| 127 RegisterUser(kTestUser1); | 150 login_manager_test_helper_->RegisterUser(kTestUser1); |
| 128 RegisterUser(kTestUser2); | 151 login_manager_test_helper_->RegisterUser(kTestUser2); |
| 129 chromeos::StartupUtils::MarkOobeCompleted(); | 152 chromeos::StartupUtils::MarkOobeCompleted(); |
| 130 } | 153 } |
| 131 | 154 |
| 132 IN_PROC_BROWSER_TEST_F(NSSContextChromeOSBrowserTest, TwoUsers) { | 155 IN_PROC_BROWSER_TEST_F(NSSContextChromeOSBrowserTest, TwoUsers) { |
| 133 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 156 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 134 | 157 |
| 135 // Log in first user and get their DB. | 158 // Log in first user and get their DB. |
| 136 LoginUser(kTestUser1); | 159 login_manager_test_helper_->LogInUser(kTestUser1); |
| 137 Profile* profile1 = | 160 Profile* profile1 = |
| 138 user_manager->GetProfileByUser(user_manager->FindUser(kTestUser1)); | 161 user_manager->GetProfileByUser(user_manager->FindUser(kTestUser1)); |
| 139 ASSERT_TRUE(profile1); | 162 ASSERT_TRUE(profile1); |
| 140 | 163 |
| 141 DBTester tester1(profile1); | 164 DBTester tester1(profile1); |
| 142 ASSERT_TRUE(tester1.DoGetDBTests()); | 165 ASSERT_TRUE(tester1.DoGetDBTests()); |
| 143 | 166 |
| 144 // Log in second user and get their DB. | 167 // Log in second user and get their DB. |
| 145 chromeos::UserAddingScreen::Get()->Start(); | 168 chromeos::UserAddingScreen::Get()->Start(); |
| 146 base::RunLoop().RunUntilIdle(); | 169 base::RunLoop().RunUntilIdle(); |
| 147 AddUser(kTestUser2); | 170 login_manager_test_helper_->AddUser(kTestUser2); |
| 148 | 171 |
| 149 Profile* profile2 = | 172 Profile* profile2 = |
| 150 user_manager->GetProfileByUser(user_manager->FindUser(kTestUser2)); | 173 user_manager->GetProfileByUser(user_manager->FindUser(kTestUser2)); |
| 151 ASSERT_TRUE(profile2); | 174 ASSERT_TRUE(profile2); |
| 152 | 175 |
| 153 DBTester tester2(profile2); | 176 DBTester tester2(profile2); |
| 154 ASSERT_TRUE(tester2.DoGetDBTests()); | 177 ASSERT_TRUE(tester2.DoGetDBTests()); |
| 155 | 178 |
| 156 // Get both DBs again to check that the same object is returned. | 179 // Get both DBs again to check that the same object is returned. |
| 157 tester1.DoGetDBAgainTests(); | 180 tester1.DoGetDBAgainTests(); |
| 158 tester2.DoGetDBAgainTests(); | 181 tester2.DoGetDBAgainTests(); |
| 159 | 182 |
| 160 // Check that each user has a separate DB and NSS slots. | 183 // Check that each user has a separate DB and NSS slots. |
| 161 tester1.DoNotEqualsTests(&tester2); | 184 tester1.DoNotEqualsTests(&tester2); |
| 162 } | 185 } |
| OLD | NEW |