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

Side by Side Diff: chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: rebased Created 5 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devtools/device/webrtc/devtools_bridge_client_browserte st.h" 5 #include "chrome/browser/devtools/device/webrtc/devtools_bridge_client_browserte st.h"
6 6
7 #include "chrome/browser/devtools/device/webrtc/devtools_bridge_client.h" 7 #include "chrome/browser/devtools/device/webrtc/devtools_bridge_client.h"
8 #include "chrome/browser/local_discovery/gcd_api_flow.h" 8 #include "chrome/browser/local_discovery/gcd_api_flow.h"
9 #include "chrome/browser/signin/account_tracker_service_factory.h"
9 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
10 #include "chrome/browser/signin/fake_signin_manager.h" 11 #include "chrome/browser/signin/fake_signin_manager.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "components/signin/core/browser/account_tracker_service.h"
12 #include "content/public/browser/web_ui_message_handler.h" 14 #include "content/public/browser/web_ui_message_handler.h"
13 15
16 namespace {
17
18 const char kGaiaId[] = "stub-user@example.com";
19 const char kUsername[] = "stub-user@example.com";
20
21 } // namespace
22
14 class DevToolsBridgeClientBrowserTest::GCDApiFlowMock 23 class DevToolsBridgeClientBrowserTest::GCDApiFlowMock
15 : public local_discovery::GCDApiFlow { 24 : public local_discovery::GCDApiFlow {
16 public: 25 public:
17 explicit GCDApiFlowMock(DevToolsBridgeClientBrowserTest* test) 26 explicit GCDApiFlowMock(DevToolsBridgeClientBrowserTest* test)
18 : test_(test), id_(++test->last_flow_id_) { 27 : test_(test), id_(++test->last_flow_id_) {
19 test_->flows_[id_] = this; 28 test_->flows_[id_] = this;
20 } 29 }
21 30
22 ~GCDApiFlowMock() override { test_->flows_.erase(id_); } 31 ~GCDApiFlowMock() override { test_->flows_.erase(id_); }
23 32
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 test_->RunJavascriptFunction("callbacks.browserListUpdated", 81 test_->RunJavascriptFunction("callbacks.browserListUpdated",
73 new base::FundamentalValue(count)); 82 new base::FundamentalValue(count));
74 } 83 }
75 84
76 scoped_ptr<local_discovery::GCDApiFlow> CreateGCDApiFlow() override { 85 scoped_ptr<local_discovery::GCDApiFlow> CreateGCDApiFlow() override {
77 return make_scoped_ptr(new GCDApiFlowMock(test_)); 86 return make_scoped_ptr(new GCDApiFlowMock(test_));
78 } 87 }
79 88
80 void GoogleSigninSucceeded() { 89 void GoogleSigninSucceeded() {
81 // This username is checked on Chrome OS. 90 // This username is checked on Chrome OS.
82 const std::string username = "stub-user@example.com"; 91 const std::string account_id =
83 test_->fake_signin_manager_->SetAuthenticatedUsername(username); 92 AccountTrackerServiceFactory::GetForProfile(
84 identity_provider().GoogleSigninSucceeded("test_account", username, 93 test_->browser()->profile())
85 "testing"); 94 ->PickAccountIdForAccount(kGaiaId, kUsername);
95 test_->fake_signin_manager_->SetAuthenticatedAccountInfo(kGaiaId,
96 kUsername);
97 identity_provider().GoogleSigninSucceeded(account_id, kUsername,
98 "password");
86 } 99 }
87 100
88 private: 101 private:
89 DevToolsBridgeClientBrowserTest* const test_; 102 DevToolsBridgeClientBrowserTest* const test_;
90 }; 103 };
91 104
92 class DevToolsBridgeClientBrowserTest::MessageHandler 105 class DevToolsBridgeClientBrowserTest::MessageHandler
93 : public content::WebUIMessageHandler { 106 : public content::WebUIMessageHandler {
94 public: 107 public:
95 explicit MessageHandler(DevToolsBridgeClientBrowserTest* test) 108 explicit MessageHandler(DevToolsBridgeClientBrowserTest* test)
96 : test_(test) {} 109 : test_(test) {}
97 110
98 void RegisterMessages() override { 111 void RegisterMessages() override {
99 web_ui()->RegisterMessageCallback( 112 web_ui()->RegisterMessageCallback(
100 "signIn", base::Bind(&MessageHandler::SignIn, base::Unretained(this))); 113 "signIn", base::Bind(&MessageHandler::SignIn, base::Unretained(this)));
101 web_ui()->RegisterMessageCallback( 114 web_ui()->RegisterMessageCallback(
102 "gcdApiResponse", 115 "gcdApiResponse",
103 base::Bind(&MessageHandler::GCDApiResponse, base::Unretained(this))); 116 base::Bind(&MessageHandler::GCDApiResponse, base::Unretained(this)));
104 web_ui()->RegisterMessageCallback( 117 web_ui()->RegisterMessageCallback(
105 "queryDevices", 118 "queryDevices",
106 base::Bind(&MessageHandler::QueryDevices, base::Unretained(this))); 119 base::Bind(&MessageHandler::QueryDevices, base::Unretained(this)));
107 } 120 }
108 121
109 void SignIn(const base::ListValue*) { 122 void SignIn(const base::ListValue*) {
110 if (test_->client_mock_.get()) 123 if (test_->client_mock_.get())
111 test_->client_mock_->GoogleSigninSucceeded(); 124 test_->client_mock_->GoogleSigninSucceeded();
112 test_->fake_token_service_->UpdateCredentials("test_user@gmail.com", 125 const std::string account_id =
113 "token"); 126 AccountTrackerServiceFactory::GetForProfile(
127 test_->browser()->profile())->PickAccountIdForAccount(kGaiaId,
128 kUsername);
129 test_->fake_token_service_->UpdateCredentials(account_id, "token");
114 } 130 }
115 131
116 void GCDApiResponse(const base::ListValue* params) { 132 void GCDApiResponse(const base::ListValue* params) {
117 CHECK(params->GetSize() >= 2); 133 CHECK(params->GetSize() >= 2);
118 int id; 134 int id;
119 const base::DictionaryValue* response; 135 const base::DictionaryValue* response;
120 CHECK(params->GetInteger(0, &id)); 136 CHECK(params->GetInteger(0, &id));
121 CHECK(params->GetDictionary(1, &response)); 137 CHECK(params->GetDictionary(1, &response));
122 138
123 auto flow = test_->flows_.find(id); 139 auto flow = test_->flows_.find(id);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 fake_signin_manager_.reset(); 174 fake_signin_manager_.reset();
159 WebUIBrowserTest::TearDownOnMainThread(); 175 WebUIBrowserTest::TearDownOnMainThread();
160 } 176 }
161 177
162 content::WebUIMessageHandler* 178 content::WebUIMessageHandler*
163 DevToolsBridgeClientBrowserTest::GetMockMessageHandler() { 179 DevToolsBridgeClientBrowserTest::GetMockMessageHandler() {
164 if (!handler_.get()) 180 if (!handler_.get())
165 handler_.reset(new MessageHandler(this)); 181 handler_.reset(new MessageHandler(this));
166 return handler_.get(); 182 return handler_.get();
167 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698