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

Side by Side Diff: chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc

Issue 763673002: Replace direct access to kGoogleServicesUsername with calls to SigninManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nullptr Created 6 years 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
« no previous file with comments | « chrome/browser/ui/webui/history_ui.cc ('k') | chrome/browser/ui/webui/ntp/ntp_login_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "chrome/browser/local_discovery/test_service_discovery_client.h" 12 #include "chrome/browser/local_discovery/test_service_discovery_client.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
15 #include "chrome/browser/signin/signin_manager_factory.h" 15 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" 17 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h"
18 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
20 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
21 #include "chrome/test/base/web_ui_browser_test.h" 22 #include "chrome/test/base/web_ui_browser_test.h"
23 #include "chromeos/chromeos_switches.h"
22 #include "components/signin/core/browser/profile_oauth2_token_service.h" 24 #include "components/signin/core/browser/profile_oauth2_token_service.h"
23 #include "components/signin/core/browser/signin_manager.h" 25 #include "components/signin/core/browser/signin_manager.h"
24 #include "components/signin/core/browser/signin_manager_base.h" 26 #include "components/signin/core/browser/signin_manager_base.h"
25 #include "google_apis/gaia/gaia_urls.h" 27 #include "google_apis/gaia/gaia_urls.h"
26 #include "net/http/http_status_code.h" 28 #include "net/http/http_status_code.h"
27 #include "net/url_request/test_url_fetcher_factory.h" 29 #include "net/url_request/test_url_fetcher_factory.h"
28 #include "net/url_request/url_request_status.h" 30 #include "net/url_request/url_request_status.h"
29 #include "net/url_request/url_request_test_util.h" 31 #include "net/url_request/url_request_test_util.h"
30 32
31 #if defined(OS_CHROMEOS) 33 #if defined(OS_CHROMEOS)
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 *test_service_discovery_client_.get(), 356 *test_service_discovery_client_.get(),
355 OnSendTo(std::string((const char*)kQueryData, sizeof(kQueryData)))) 357 OnSendTo(std::string((const char*)kQueryData, sizeof(kQueryData))))
356 .Times(AtLeast(2)) 358 .Times(AtLeast(2))
357 .WillOnce(InvokeWithoutArgs(&condition_devices_listed_, 359 .WillOnce(InvokeWithoutArgs(&condition_devices_listed_,
358 &TestMessageLoopCondition::Signal)) 360 &TestMessageLoopCondition::Signal))
359 .WillRepeatedly(Return()); 361 .WillRepeatedly(Return());
360 362
361 SigninManagerBase* signin_manager = 363 SigninManagerBase* signin_manager =
362 SigninManagerFactory::GetForProfile(browser()->profile()); 364 SigninManagerFactory::GetForProfile(browser()->profile());
363 365
364 #if defined(OS_CHROMEOS)
365 // Chrome OS initializes prefs::kGoogleServicesUsername to "stub user" so
366 // we need to override it as well.
367 browser()->profile()->GetPrefs()->
368 SetString(prefs::kGoogleServicesUsername, kSampleUser);
369 #endif
370 DCHECK(signin_manager); 366 DCHECK(signin_manager);
371 signin_manager->SetAuthenticatedUsername(kSampleUser); 367 signin_manager->SetAuthenticatedUsername(kSampleUser);
372 368
373 fake_fetcher_factory().SetFakeResponse( 369 fake_fetcher_factory().SetFakeResponse(
374 GURL(kURLInfo), 370 GURL(kURLInfo),
375 kResponseInfo, 371 kResponseInfo,
376 net::HTTP_OK, 372 net::HTTP_OK,
377 net::URLRequestStatus::SUCCESS); 373 net::URLRequestStatus::SUCCESS);
378 374
379 fake_fetcher_factory().SetFakeResponse( 375 fake_fetcher_factory().SetFakeResponse(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 418
423 ProfileOAuth2TokenService* token_service = 419 ProfileOAuth2TokenService* token_service =
424 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()); 420 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile());
425 421
426 token_service->UpdateCredentials("user@host.com", "MyFakeToken"); 422 token_service->UpdateCredentials("user@host.com", "MyFakeToken");
427 423
428 AddLibrary(base::FilePath(FILE_PATH_LITERAL("local_discovery_ui_test.js"))); 424 AddLibrary(base::FilePath(FILE_PATH_LITERAL("local_discovery_ui_test.js")));
429 } 425 }
430 426
431 virtual void SetUpCommandLine(CommandLine* command_line) override { 427 virtual void SetUpCommandLine(CommandLine* command_line) override {
428 #if defined(OS_CHROMEOS)
429 // On chromeos, don't sign in with the stub-user automatically. Use the
430 // kLoginUser instead.
431 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
432 kSampleUser);
433 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
434 chrome::kTestUserProfileDir);
435 #endif
432 WebUIBrowserTest::SetUpCommandLine(command_line); 436 WebUIBrowserTest::SetUpCommandLine(command_line);
433 } 437 }
434 438
435 void RunFor(base::TimeDelta time_period) { 439 void RunFor(base::TimeDelta time_period) {
436 base::CancelableCallback<void()> callback(base::Bind( 440 base::CancelableCallback<void()> callback(base::Bind(
437 &base::MessageLoop::Quit, base::Unretained( 441 &base::MessageLoop::Quit, base::Unretained(
438 base::MessageLoop::current()))); 442 base::MessageLoop::current())));
439 base::MessageLoop::current()->PostDelayedTask( 443 base::MessageLoop::current()->PostDelayedTask(
440 FROM_HERE, callback.callback(), time_period); 444 FROM_HERE, callback.callback(), time_period);
441 445
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 kAnnouncePacketRegistered, sizeof(kAnnouncePacketRegistered)); 566 kAnnouncePacketRegistered, sizeof(kAnnouncePacketRegistered));
563 567
564 base::MessageLoop::current()->RunUntilIdle(); 568 base::MessageLoop::current()->RunUntilIdle();
565 569
566 EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("expectRegisterDone")); 570 EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("expectRegisterDone"));
567 } 571 }
568 572
569 } // namespace 573 } // namespace
570 574
571 } // namespace local_discovery 575 } // namespace local_discovery
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history_ui.cc ('k') | chrome/browser/ui/webui/ntp/ntp_login_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698