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

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_browsertest.cc

Issue 427053002: Do not reload account picker when device-local account policy changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing includes, Created 6 years, 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "apps/ui/native_app_window.h" 9 #include "apps/ui/native_app_window.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/system/chromeos/session/logout_confirmation_controller.h" 11 #include "ash/system/chromeos/session/logout_confirmation_controller.h"
12 #include "ash/system/chromeos/session/logout_confirmation_dialog.h" 12 #include "ash/system/chromeos/session/logout_confirmation_dialog.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/file_util.h" 18 #include "base/file_util.h"
19 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
20 #include "base/json/json_reader.h" 20 #include "base/json/json_reader.h"
21 #include "base/json/json_writer.h" 21 #include "base/json/json_writer.h"
22 #include "base/location.h" 22 #include "base/location.h"
23 #include "base/macros.h"
23 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
24 #include "base/memory/scoped_ptr.h" 25 #include "base/memory/scoped_ptr.h"
25 #include "base/message_loop/message_loop.h" 26 #include "base/message_loop/message_loop.h"
26 #include "base/message_loop/message_loop_proxy.h" 27 #include "base/message_loop/message_loop_proxy.h"
27 #include "base/path_service.h" 28 #include "base/path_service.h"
29 #include "base/prefs/pref_change_registrar.h"
28 #include "base/prefs/pref_service.h" 30 #include "base/prefs/pref_service.h"
29 #include "base/run_loop.h" 31 #include "base/run_loop.h"
30 #include "base/sequenced_task_runner.h" 32 #include "base/sequenced_task_runner.h"
31 #include "base/strings/string_number_conversions.h" 33 #include "base/strings/string_number_conversions.h"
32 #include "base/strings/string_util.h" 34 #include "base/strings/string_util.h"
33 #include "base/strings/stringprintf.h" 35 #include "base/strings/stringprintf.h"
34 #include "base/strings/utf_string_conversions.h" 36 #include "base/strings/utf_string_conversions.h"
35 #include "base/values.h" 37 #include "base/values.h"
36 #include "chrome/browser/browser_process.h" 38 #include "chrome/browser/browser_process.h"
37 #include "chrome/browser/chrome_notification_types.h" 39 #include "chrome/browser/chrome_notification_types.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 using testing::Return; 136 using testing::Return;
135 using testing::_; 137 using testing::_;
136 138
137 namespace policy { 139 namespace policy {
138 140
139 namespace { 141 namespace {
140 142
141 const char kDomain[] = "example.com"; 143 const char kDomain[] = "example.com";
142 const char kAccountId1[] = "dla1@example.com"; 144 const char kAccountId1[] = "dla1@example.com";
143 const char kAccountId2[] = "dla2@example.com"; 145 const char kAccountId2[] = "dla2@example.com";
144 const char kDisplayName[] = "display name"; 146 const char kDisplayName1[] = "display name 1";
147 const char kDisplayName2[] = "display name 2";
145 const char* kStartupURLs[] = { 148 const char* kStartupURLs[] = {
146 "chrome://policy", 149 "chrome://policy",
147 "chrome://about", 150 "chrome://about",
148 }; 151 };
149 const char kExistentTermsOfServicePath[] = "chromeos/enterprise/tos.txt"; 152 const char kExistentTermsOfServicePath[] = "chromeos/enterprise/tos.txt";
150 const char kNonexistentTermsOfServicePath[] = "chromeos/enterprise/tos404.txt"; 153 const char kNonexistentTermsOfServicePath[] = "chromeos/enterprise/tos404.txt";
151 const char kRelativeUpdateURL[] = "/service/update2/crx"; 154 const char kRelativeUpdateURL[] = "/service/update2/crx";
152 const char kUpdateManifestHeader[] = 155 const char kUpdateManifestHeader[] =
153 "<?xml version='1.0' encoding='UTF-8'?>\n" 156 "<?xml version='1.0' encoding='UTF-8'?>\n"
154 "<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>\n"; 157 "<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>\n";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 GURL crx_url; 204 GURL crx_url;
202 }; 205 };
203 typedef std::map<std::string, Update> UpdateMap; 206 typedef std::map<std::string, Update> UpdateMap;
204 UpdateMap updates_; 207 UpdateMap updates_;
205 208
206 const std::string relative_update_url_; 209 const std::string relative_update_url_;
207 210
208 DISALLOW_COPY_AND_ASSIGN(TestingUpdateManifestProvider); 211 DISALLOW_COPY_AND_ASSIGN(TestingUpdateManifestProvider);
209 }; 212 };
210 213
214 // Helper that observes the dictionary |pref| in local state and waits until the
215 // value stored for |key| matches |expected_value|.
216 class DictionaryPrefValueWaiter {
217 public:
218 DictionaryPrefValueWaiter(const std::string& pref,
219 const std::string& key,
220 const std::string& expected_value);
221 ~DictionaryPrefValueWaiter();
222
223 void Wait();
224
225 private:
226 void QuitLoopIfExpectedValueFound();
227
228 const std::string pref_;
229 const std::string key_;
230 const std::string expected_value_;
231
232 base::RunLoop run_loop_;
233 PrefChangeRegistrar pref_change_registrar_;
234
235 DISALLOW_COPY_AND_ASSIGN(DictionaryPrefValueWaiter);
236 };
237
211 TestingUpdateManifestProvider::Update::Update(const std::string& version, 238 TestingUpdateManifestProvider::Update::Update(const std::string& version,
212 const GURL& crx_url) 239 const GURL& crx_url)
213 : version(version), 240 : version(version),
214 crx_url(crx_url) { 241 crx_url(crx_url) {
215 } 242 }
216 243
217 TestingUpdateManifestProvider::Update::Update() { 244 TestingUpdateManifestProvider::Update::Update() {
218 } 245 }
219 246
220 TestingUpdateManifestProvider::TestingUpdateManifestProvider( 247 TestingUpdateManifestProvider::TestingUpdateManifestProvider(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 284 }
258 content += kUpdateManifestFooter; 285 content += kUpdateManifestFooter;
259 scoped_ptr<net::test_server::BasicHttpResponse> 286 scoped_ptr<net::test_server::BasicHttpResponse>
260 http_response(new net::test_server::BasicHttpResponse); 287 http_response(new net::test_server::BasicHttpResponse);
261 http_response->set_code(net::HTTP_OK); 288 http_response->set_code(net::HTTP_OK);
262 http_response->set_content(content); 289 http_response->set_content(content);
263 http_response->set_content_type("text/xml"); 290 http_response->set_content_type("text/xml");
264 return http_response.PassAs<net::test_server::HttpResponse>(); 291 return http_response.PassAs<net::test_server::HttpResponse>();
265 } 292 }
266 293
294 DictionaryPrefValueWaiter::DictionaryPrefValueWaiter(
295 const std::string& pref,
296 const std::string& key,
297 const std::string& expected_value)
298 : pref_(pref),
299 key_(key),
300 expected_value_(expected_value) {
301 pref_change_registrar_.Init(g_browser_process->local_state());
302 }
303
304 DictionaryPrefValueWaiter::~DictionaryPrefValueWaiter() {
305 }
306
307 void DictionaryPrefValueWaiter::Wait() {
308 pref_change_registrar_.Add(
309 pref_.c_str(),
310 base::Bind(&DictionaryPrefValueWaiter::QuitLoopIfExpectedValueFound,
311 base::Unretained(this)));
312 QuitLoopIfExpectedValueFound();
313 run_loop_.Run();
314 }
315
316 void DictionaryPrefValueWaiter::QuitLoopIfExpectedValueFound() {
317 const base::DictionaryValue* pref =
318 pref_change_registrar_.prefs()->GetDictionary(pref_.c_str());
319 ASSERT_TRUE(pref);
320 std::string actual_value;
321 if (pref->GetStringWithoutPathExpansion(key_, &actual_value) &&
322 actual_value == expected_value_) {
323 run_loop_.Quit();
324 }
325 }
326
267 bool DoesInstallSuccessReferToId(const std::string& id, 327 bool DoesInstallSuccessReferToId(const std::string& id,
268 const content::NotificationSource& source, 328 const content::NotificationSource& source,
269 const content::NotificationDetails& details) { 329 const content::NotificationDetails& details) {
270 return content::Details<const extensions::InstalledExtensionInfo>(details)-> 330 return content::Details<const extensions::InstalledExtensionInfo>(details)->
271 extension->id() == id; 331 extension->id() == id;
272 } 332 }
273 333
274 bool DoesInstallFailureReferToId(const std::string& id, 334 bool DoesInstallFailureReferToId(const std::string& id,
275 const content::NotificationSource& source, 335 const content::NotificationSource& source,
276 const content::NotificationDetails& details) { 336 const content::NotificationDetails& details) {
277 return content::Details<const base::string16>(details)-> 337 return content::Details<const base::string16>(details)->
278 find(base::UTF8ToUTF16(id)) != base::string16::npos; 338 find(base::UTF8ToUTF16(id)) != base::string16::npos;
279 } 339 }
280 340
281 scoped_ptr<net::FakeURLFetcher> RunCallbackAndReturnFakeURLFetcher( 341 scoped_ptr<net::FakeURLFetcher> RunCallbackAndReturnFakeURLFetcher(
282 scoped_refptr<base::SequencedTaskRunner> task_runner, 342 scoped_refptr<base::SequencedTaskRunner> task_runner,
283 const base::Closure& callback, 343 const base::Closure& callback,
284 const GURL& url, 344 const GURL& url,
285 net::URLFetcherDelegate* delegate, 345 net::URLFetcherDelegate* delegate,
286 const std::string& response_data, 346 const std::string& response_data,
287 net::HttpStatusCode response_code, 347 net::HttpStatusCode response_code,
288 net::URLRequestStatus::Status status) { 348 net::URLRequestStatus::Status status) {
289 task_runner->PostTask(FROM_HERE, callback); 349 task_runner->PostTask(FROM_HERE, callback);
290 return make_scoped_ptr(new net::FakeURLFetcher( 350 return make_scoped_ptr(new net::FakeURLFetcher(
291 url, delegate, response_data, response_code, status)); 351 url, delegate, response_data, response_code, status));
292 } 352 }
293 353
294 bool DisplayNameMatches(const std::string& account_id,
295 const std::string& display_name) {
296 const user_manager::User* user =
297 chromeos::UserManager::Get()->FindUser(account_id);
298 if (!user || user->display_name().empty())
299 return false;
300 EXPECT_EQ(base::UTF8ToUTF16(display_name), user->display_name());
301 return true;
302 }
303
304 bool IsSessionStarted() { 354 bool IsSessionStarted() {
305 return chromeos::UserManager::Get()->IsSessionStarted(); 355 return chromeos::UserManager::Get()->IsSessionStarted();
306 } 356 }
307 357
308 } // namespace 358 } // namespace
309 359
310 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, 360 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest,
311 public chromeos::UserManager::Observer, 361 public chromeos::UserManager::Observer,
312 public chrome::BrowserListObserver, 362 public chrome::BrowserListObserver,
313 public apps::AppWindowRegistry::Observer { 363 public apps::AppWindowRegistry::Observer {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); 451 em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
402 proto.mutable_show_user_names()->set_show_user_names(true); 452 proto.mutable_show_user_names()->set_show_user_names(true);
403 453
404 device_local_account_policy_.policy_data().set_policy_type( 454 device_local_account_policy_.policy_data().set_policy_type(
405 dm_protocol::kChromePublicAccountPolicyType); 455 dm_protocol::kChromePublicAccountPolicyType);
406 device_local_account_policy_.policy_data().set_username(kAccountId1); 456 device_local_account_policy_.policy_data().set_username(kAccountId1);
407 device_local_account_policy_.policy_data().set_settings_entity_id( 457 device_local_account_policy_.policy_data().set_settings_entity_id(
408 kAccountId1); 458 kAccountId1);
409 device_local_account_policy_.policy_data().set_public_key_version(1); 459 device_local_account_policy_.policy_data().set_public_key_version(1);
410 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( 460 device_local_account_policy_.payload().mutable_userdisplayname()->set_value(
411 kDisplayName); 461 kDisplayName1);
412 } 462 }
413 463
414 void BuildDeviceLocalAccountPolicy() { 464 void BuildDeviceLocalAccountPolicy() {
415 device_local_account_policy_.SetDefaultSigningKey(); 465 device_local_account_policy_.SetDefaultSigningKey();
416 device_local_account_policy_.Build(); 466 device_local_account_policy_.Build();
417 } 467 }
418 468
419 void UploadDeviceLocalAccountPolicy() { 469 void UploadDeviceLocalAccountPolicy() {
420 BuildDeviceLocalAccountPolicy(); 470 BuildDeviceLocalAccountPolicy();
421 test_server_.UpdatePolicy( 471 test_server_.UpdatePolicy(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 return GetExtensionCacheDirectoryForAccountID(account_id) 515 return GetExtensionCacheDirectoryForAccountID(account_id)
466 .Append(base::StringPrintf("%s-%s.crx", id.c_str(), version.c_str())); 516 .Append(base::StringPrintf("%s-%s.crx", id.c_str(), version.c_str()));
467 } 517 }
468 518
469 // Returns a profile which can be used for testing. 519 // Returns a profile which can be used for testing.
470 Profile* GetProfileForTest() { 520 Profile* GetProfileForTest() {
471 // Any profile can be used here since this test does not test multi profile. 521 // Any profile can be used here since this test does not test multi profile.
472 return ProfileManager::GetActiveUserProfile(); 522 return ProfileManager::GetActiveUserProfile();
473 } 523 }
474 524
525 void WaitForDisplayName(const std::string& user_id,
526 const std::string& expected_display_name) {
527 DictionaryPrefValueWaiter("UserDisplayName",
528 user_id,
529 expected_display_name).Wait();
530 }
531
475 void WaitForPolicy() { 532 void WaitForPolicy() {
476 // This observes the display name becoming available as this indicates 533 // Wait for the display name becoming available as that indicates
477 // device-local account policy is fully loaded, which is a prerequisite for 534 // device-local account policy is fully loaded, which is a prerequisite for
478 // successful login. 535 // successful login.
479 content::WindowedNotificationObserver( 536 WaitForDisplayName(user_id_1_, kDisplayName1);
480 chrome::NOTIFICATION_USER_LIST_CHANGED,
481 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait();
482 } 537 }
483 538
484 void WaitForLoginUI() { 539 void WaitForLoginUI() {
485 // Wait for the login UI to be ready. 540 // Wait for the login UI to be ready.
486 chromeos::LoginDisplayHostImpl* host = 541 chromeos::LoginDisplayHostImpl* host =
487 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( 542 reinterpret_cast<chromeos::LoginDisplayHostImpl*>(
488 chromeos::LoginDisplayHostImpl::default_host()); 543 chromeos::LoginDisplayHostImpl::default_host());
489 ASSERT_TRUE(host); 544 ASSERT_TRUE(host);
490 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); 545 chromeos::OobeUI* oobe_ui = host->GetOobeUI();
491 ASSERT_TRUE(oobe_ui); 546 ASSERT_TRUE(oobe_ui);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 return chromeos::UserManager::Get()->IsKnownUser(account_id); 593 return chromeos::UserManager::Get()->IsKnownUser(account_id);
539 } 594 }
540 595
541 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { 596 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) {
542 AddPublicSessionToDevicePolicy(kAccountId1); 597 AddPublicSessionToDevicePolicy(kAccountId1);
543 AddPublicSessionToDevicePolicy(kAccountId2); 598 AddPublicSessionToDevicePolicy(kAccountId2);
544 599
545 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 600 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED,
546 base::Bind(&IsKnownUser, user_id_1_)) 601 base::Bind(&IsKnownUser, user_id_1_))
547 .Wait(); 602 .Wait();
548 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 603 EXPECT_TRUE(IsKnownUser(user_id_2_));
549 base::Bind(&IsKnownUser, user_id_2_))
550 .Wait();
551 604
552 CheckPublicSessionPresent(user_id_1_); 605 CheckPublicSessionPresent(user_id_1_);
553 CheckPublicSessionPresent(user_id_2_); 606 CheckPublicSessionPresent(user_id_2_);
554 } 607 }
555 608
556 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DisplayName) { 609 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DisplayName) {
557 UploadAndInstallDeviceLocalAccountPolicy(); 610 UploadAndInstallDeviceLocalAccountPolicy();
558 AddPublicSessionToDevicePolicy(kAccountId1); 611 AddPublicSessionToDevicePolicy(kAccountId1);
559 612
560 WaitForPolicy(); 613 WaitForPolicy();
614
615 // Skip to the login screen.
616 chromeos::WizardController* wizard_controller =
617 chromeos::WizardController::default_controller();
618 ASSERT_TRUE(wizard_controller);
619 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
620 content::WindowedNotificationObserver(
621 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
622 content::NotificationService::AllSources()).Wait();
623
624 // Verify that the display name is shown in the UI.
625 chromeos::LoginDisplayHostImpl* host =
626 reinterpret_cast<chromeos::LoginDisplayHostImpl*>(
627 chromeos::LoginDisplayHostImpl::default_host());
628 ASSERT_TRUE(host);
629 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView();
630 ASSERT_TRUE(web_ui_login_view);
631 content::WebUI* web_ui = web_ui_login_view->GetWebUI();
632 ASSERT_TRUE(web_ui);
633 content::WebContents* contents = web_ui->GetWebContents();
634 ASSERT_TRUE(contents);
635 const std::string get_compact_pod_display_name = base::StringPrintf(
636 "domAutomationController.send(document.getElementById('pod-row')"
637 " .getPodWithUsername_('%s').nameElement.textContent);",
638 user_id_1_.c_str());
639 std::string display_name;
640 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
641 contents,
642 get_compact_pod_display_name,
643 &display_name));
644 EXPECT_EQ(kDisplayName1, display_name);
645 const std::string get_expanded_pod_display_name = base::StringPrintf(
646 "domAutomationController.send(document.getElementById('pod-row')"
647 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')"
648 " .textContent);",
649 user_id_1_.c_str());
650 display_name.clear();
651 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
652 contents,
653 get_expanded_pod_display_name,
654 &display_name));
655 EXPECT_EQ(kDisplayName1, display_name);
656
657 // Click on the pod to expand it.
658 ASSERT_TRUE(content::ExecuteScript(
659 contents,
660 base::StringPrintf(
661 "document.getElementById('pod-row').getPodWithUsername_('%s')"
662 " .click();",
663 user_id_1_.c_str())));
664
665 // Change the display name.
666 device_local_account_policy_.payload().mutable_userdisplayname()->set_value(
667 kDisplayName2);
668 UploadAndInstallDeviceLocalAccountPolicy();
669 policy::BrowserPolicyConnectorChromeOS* connector =
670 g_browser_process->platform_part()->browser_policy_connector_chromeos();
671 DeviceLocalAccountPolicyBroker* broker =
672 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser(
673 user_id_1_);
674 ASSERT_TRUE(broker);
675 broker->core()->store()->Load();
676 WaitForDisplayName(user_id_1_, kDisplayName2);
677
678 // Verify that the new display name is shown in the UI.
679 display_name.clear();
680 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
681 contents,
682 get_compact_pod_display_name,
683 &display_name));
684 EXPECT_EQ(kDisplayName2, display_name);
685 display_name.clear();
686 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
687 contents,
688 get_expanded_pod_display_name,
689 &display_name));
690 EXPECT_EQ(kDisplayName2, display_name);
691
692 // Verify that the pod is still expanded. This indicates that the UI updated
693 // without reloading and losing state.
694 bool expanded = false;
695 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
696 contents,
697 base::StringPrintf(
698 "domAutomationController.send(document.getElementById('pod-row')"
699 " .getPodWithUsername_('%s').expanded);",
700 user_id_1_.c_str()),
701 &expanded));
702 EXPECT_TRUE(expanded);
561 } 703 }
562 704
563 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { 705 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) {
564 UploadDeviceLocalAccountPolicy(); 706 UploadDeviceLocalAccountPolicy();
565 AddPublicSessionToDevicePolicy(kAccountId1); 707 AddPublicSessionToDevicePolicy(kAccountId1);
566 708
567 WaitForPolicy(); 709 WaitForPolicy();
568 710
569 // Sanity check: The policy should be present now. 711 // Sanity check: The policy should be present now.
570 ASSERT_FALSE(session_manager_client()->device_local_account_policy( 712 ASSERT_FALSE(session_manager_client()->device_local_account_policy(
571 kAccountId1).empty()); 713 kAccountId1).empty());
572 } 714 }
573 715
574 static bool IsNotKnownUser(const std::string& account_id) { 716 static bool IsNotKnownUser(const std::string& account_id) {
575 return !IsKnownUser(account_id); 717 return !IsKnownUser(account_id);
576 } 718 }
577 719
578 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DevicePolicyChange) { 720 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, AccountListChange) {
579 AddPublicSessionToDevicePolicy(kAccountId1); 721 AddPublicSessionToDevicePolicy(kAccountId1);
580 AddPublicSessionToDevicePolicy(kAccountId2); 722 AddPublicSessionToDevicePolicy(kAccountId2);
581 723
582 // Wait until the login screen is up.
583 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 724 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED,
584 base::Bind(&IsKnownUser, user_id_1_)) 725 base::Bind(&IsKnownUser, user_id_1_))
585 .Wait(); 726 .Wait();
586 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 727 EXPECT_TRUE(IsKnownUser(user_id_2_));
587 base::Bind(&IsKnownUser, user_id_2_))
588 .Wait();
589 728
590 // Update policy to remove kAccountId2. 729 // Update policy to remove kAccountId2.
591 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); 730 em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
592 proto.mutable_device_local_accounts()->clear_account(); 731 proto.mutable_device_local_accounts()->clear_account();
593 AddPublicSessionToDevicePolicy(kAccountId1); 732 AddPublicSessionToDevicePolicy(kAccountId1);
594 733
595 em::ChromeDeviceSettingsProto policy; 734 em::ChromeDeviceSettingsProto policy;
596 policy.mutable_show_user_names()->set_show_user_names(true); 735 policy.mutable_show_user_names()->set_show_user_names(true);
597 em::DeviceLocalAccountInfoProto* account1 = 736 em::DeviceLocalAccountInfoProto* account1 =
598 policy.mutable_device_local_accounts()->add_account(); 737 policy.mutable_device_local_accounts()->add_account();
599 account1->set_account_id(kAccountId1); 738 account1->set_account_id(kAccountId1);
600 account1->set_type( 739 account1->set_type(
601 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); 740 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION);
602 741
603 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(), 742 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(),
604 policy.SerializeAsString()); 743 policy.SerializeAsString());
605 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); 744 g_browser_process->policy_service()->RefreshPolicies(base::Closure());
606 745
607 // Make sure the second device-local account disappears. 746 // Make sure the second device-local account disappears.
608 content::WindowedNotificationObserver( 747 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED,
609 chrome::NOTIFICATION_USER_LIST_CHANGED, 748 base::Bind(&IsNotKnownUser, user_id_2_))
610 base::Bind(&IsNotKnownUser, user_id_2_)).Wait(); 749 .Wait();
611 } 750 }
612 751
613 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) { 752 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) {
614 // Specify startup pages. 753 // Specify startup pages.
615 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( 754 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value(
616 SessionStartupPref::kPrefValueURLs); 755 SessionStartupPref::kPrefValueURLs);
617 em::StringListPolicyProto* startup_urls_proto = 756 em::StringListPolicyProto* startup_urls_proto =
618 device_local_account_policy_.payload().mutable_restoreonstartupurls(); 757 device_local_account_policy_.payload().mutable_restoreonstartupurls();
619 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) 758 for (size_t i = 0; i < arraysize(kStartupURLs); ++i)
620 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]); 759 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]);
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 ASSERT_TRUE(content::ExecuteScript(contents, 1563 ASSERT_TRUE(content::ExecuteScript(contents,
1425 "$('tos-accept-button').click();")); 1564 "$('tos-accept-button').click();"));
1426 1565
1427 WaitForSessionStart(); 1566 WaitForSessionStart();
1428 } 1567 }
1429 1568
1430 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, 1569 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance,
1431 TermsOfServiceDownloadTest, testing::Bool()); 1570 TermsOfServiceDownloadTest, testing::Bool());
1432 1571
1433 } // namespace policy 1572 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698