Commit d2a3645c authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove using directives ("using namespace x") from chrome/browser/chromeos/.

Also other misc. cleanup, e.g. use make_unique more.

Bug: 82078
Change-Id: Ibe4384e74b905d4fc60392edf258663ddc6bc5a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844339
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703234}
parent 6adb0722
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "ui/base/ime/chromeos/input_method_whitelist.h" #include "ui/base/ime/chromeos/input_method_whitelist.h"
#include "ui/base/ime/ime_bridge.h" #include "ui/base/ime/ime_bridge.h"
using namespace chromeos::input_method; using chromeos::input_method::InputMethodManager;
namespace { namespace {
...@@ -62,7 +62,8 @@ class TestListener : public content::NotificationObserver { ...@@ -62,7 +62,8 @@ class TestListener : public content::NotificationObserver {
// background. // background.
InputMethodManager* manager = InputMethodManager::Get(); InputMethodManager* manager = InputMethodManager::Get();
manager->GetInputMethodUtil()->InitXkbInputMethodsForTesting( manager->GetInputMethodUtil()->InitXkbInputMethodsForTesting(
*InputMethodWhitelist().GetSupportedInputMethods()); *chromeos::input_method::InputMethodWhitelist()
.GetSupportedInputMethods());
std::vector<std::string> keyboard_layouts; std::vector<std::string> keyboard_layouts;
keyboard_layouts.push_back( keyboard_layouts.push_back(
...@@ -157,7 +158,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, ImeMenuAPITest) { ...@@ -157,7 +158,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, ImeMenuAPITest) {
extension_ime_ids.push_back(kTestIMEID2); extension_ime_ids.push_back(kTestIMEID2);
InputMethodManager::Get()->GetActiveIMEState()->SetEnabledExtensionImes( InputMethodManager::Get()->GetActiveIMEState()->SetEnabledExtensionImes(
&extension_ime_ids); &extension_ime_ids);
InputMethodDescriptors extension_imes; chromeos::input_method::InputMethodDescriptors extension_imes;
InputMethodManager::Get()->GetActiveIMEState()->GetInputMethodExtensions( InputMethodManager::Get()->GetActiveIMEState()->GetInputMethodExtensions(
&extension_imes); &extension_imes);
InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod( InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod(
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "extensions/browser/api_test_utils.h" #include "extensions/browser/api_test_utils.h"
#include "extensions/browser/extension_function_dispatcher.h" #include "extensions/browser/extension_function_dispatcher.h"
using namespace extensions;
namespace quick_unlock_private = extensions::api::quick_unlock_private; namespace quick_unlock_private = extensions::api::quick_unlock_private;
using CredentialCheck = quick_unlock_private::CredentialCheck; using CredentialCheck = quick_unlock_private::CredentialCheck;
using CredentialProblem = quick_unlock_private::CredentialProblem; using CredentialProblem = quick_unlock_private::CredentialProblem;
...@@ -50,10 +49,6 @@ using QuickUnlockMode = quick_unlock_private::QuickUnlockMode; ...@@ -50,10 +49,6 @@ using QuickUnlockMode = quick_unlock_private::QuickUnlockMode;
using QuickUnlockModeList = std::vector<QuickUnlockMode>; using QuickUnlockModeList = std::vector<QuickUnlockMode>;
using CredentialList = std::vector<std::string>; using CredentialList = std::vector<std::string>;
using ::testing::_;
using ::testing::Invoke;
using ::testing::WithArgs;
namespace chromeos { namespace chromeos {
namespace { namespace {
...@@ -132,7 +127,7 @@ enum ExpectedPinState { ...@@ -132,7 +127,7 @@ enum ExpectedPinState {
} // namespace } // namespace
class QuickUnlockPrivateUnitTest class QuickUnlockPrivateUnitTest
: public ExtensionApiUnittest, : public extensions::ExtensionApiUnittest,
public ::testing::WithParamInterface<TestType> { public ::testing::WithParamInterface<TestType> {
public: public:
QuickUnlockPrivateUnitTest() = default; QuickUnlockPrivateUnitTest() = default;
...@@ -224,7 +219,7 @@ class QuickUnlockPrivateUnitTest ...@@ -224,7 +219,7 @@ class QuickUnlockPrivateUnitTest
std::unique_ptr<quick_unlock_private::TokenInfo> GetAuthToken( std::unique_ptr<quick_unlock_private::TokenInfo> GetAuthToken(
const std::string& password) { const std::string& password) {
// Setup a fake authenticator to avoid calling cryptohome methods. // Setup a fake authenticator to avoid calling cryptohome methods.
auto* func = new QuickUnlockPrivateGetAuthTokenFunction(); auto* func = new extensions::QuickUnlockPrivateGetAuthTokenFunction();
func->SetAuthenticatorAllocatorForTesting( func->SetAuthenticatorAllocatorForTesting(
base::Bind(&CreateFakeAuthenticator)); base::Bind(&CreateFakeAuthenticator));
...@@ -241,7 +236,7 @@ class QuickUnlockPrivateUnitTest ...@@ -241,7 +236,7 @@ class QuickUnlockPrivateUnitTest
// password. Expects the function to fail and returns the error. // password. Expects the function to fail and returns the error.
std::string RunAuthTokenWithInvalidPassword() { std::string RunAuthTokenWithInvalidPassword() {
// Setup a fake authenticator to avoid calling cryptohome methods. // Setup a fake authenticator to avoid calling cryptohome methods.
auto* func = new QuickUnlockPrivateGetAuthTokenFunction(); auto* func = new extensions::QuickUnlockPrivateGetAuthTokenFunction();
func->SetAuthenticatorAllocatorForTesting( func->SetAuthenticatorAllocatorForTesting(
base::Bind(&CreateFakeAuthenticator)); base::Bind(&CreateFakeAuthenticator));
...@@ -255,8 +250,9 @@ class QuickUnlockPrivateUnitTest ...@@ -255,8 +250,9 @@ class QuickUnlockPrivateUnitTest
auto params = std::make_unique<base::ListValue>(); auto params = std::make_unique<base::ListValue>();
params->AppendString(token); params->AppendString(token);
params->AppendBoolean(enabled); params->AppendBoolean(enabled);
RunFunction(new QuickUnlockPrivateSetLockScreenEnabledFunction(), RunFunction(
std::move(params)); new extensions::QuickUnlockPrivateSetLockScreenEnabledFunction(),
std::move(params));
} }
// Wrapper for chrome.quickUnlockPrivate.setLockScreenEnabled. // Wrapper for chrome.quickUnlockPrivate.setLockScreenEnabled.
...@@ -265,16 +261,16 @@ class QuickUnlockPrivateUnitTest ...@@ -265,16 +261,16 @@ class QuickUnlockPrivateUnitTest
params->AppendString(kInvalidToken); params->AppendString(kInvalidToken);
params->AppendBoolean(enabled); params->AppendBoolean(enabled);
return RunFunctionAndReturnError( return RunFunctionAndReturnError(
new QuickUnlockPrivateSetLockScreenEnabledFunction(), new extensions::QuickUnlockPrivateSetLockScreenEnabledFunction(),
std::move(params)); std::move(params));
} }
// Wrapper for chrome.quickUnlockPrivate.getAvailableModes. // Wrapper for chrome.quickUnlockPrivate.getAvailableModes.
QuickUnlockModeList GetAvailableModes() { QuickUnlockModeList GetAvailableModes() {
// Run the function. // Run the function.
std::unique_ptr<base::Value> result = std::unique_ptr<base::Value> result = RunFunction(
RunFunction(new QuickUnlockPrivateGetAvailableModesFunction(), new extensions::QuickUnlockPrivateGetAvailableModesFunction(),
std::make_unique<base::ListValue>()); std::make_unique<base::ListValue>());
// Extract the results. // Extract the results.
QuickUnlockModeList modes; QuickUnlockModeList modes;
...@@ -293,7 +289,7 @@ class QuickUnlockPrivateUnitTest ...@@ -293,7 +289,7 @@ class QuickUnlockPrivateUnitTest
// Wrapper for chrome.quickUnlockPrivate.getActiveModes. // Wrapper for chrome.quickUnlockPrivate.getActiveModes.
QuickUnlockModeList GetActiveModes() { QuickUnlockModeList GetActiveModes() {
std::unique_ptr<base::Value> result = std::unique_ptr<base::Value> result =
RunFunction(new QuickUnlockPrivateGetActiveModesFunction(), RunFunction(new extensions::QuickUnlockPrivateGetActiveModesFunction(),
std::make_unique<base::ListValue>()); std::make_unique<base::ListValue>());
QuickUnlockModeList modes; QuickUnlockModeList modes;
...@@ -344,8 +340,9 @@ class QuickUnlockPrivateUnitTest ...@@ -344,8 +340,9 @@ class QuickUnlockPrivateUnitTest
params->AppendString(ToString(QuickUnlockMode::QUICK_UNLOCK_MODE_PIN)); params->AppendString(ToString(QuickUnlockMode::QUICK_UNLOCK_MODE_PIN));
params->AppendString(pin); params->AppendString(pin);
std::unique_ptr<base::Value> result = RunFunction( std::unique_ptr<base::Value> result =
new QuickUnlockPrivateCheckCredentialFunction(), std::move(params)); RunFunction(new extensions::QuickUnlockPrivateCheckCredentialFunction(),
std::move(params));
CredentialCheck function_result; CredentialCheck function_result;
EXPECT_TRUE(CredentialCheck::Populate(*result, &function_result)); EXPECT_TRUE(CredentialCheck::Populate(*result, &function_result));
...@@ -357,9 +354,9 @@ class QuickUnlockPrivateUnitTest ...@@ -357,9 +354,9 @@ class QuickUnlockPrivateUnitTest
auto params = std::make_unique<base::ListValue>(); auto params = std::make_unique<base::ListValue>();
params->AppendString(ToString(QuickUnlockMode::QUICK_UNLOCK_MODE_PIN)); params->AppendString(ToString(QuickUnlockMode::QUICK_UNLOCK_MODE_PIN));
std::unique_ptr<base::Value> result = std::unique_ptr<base::Value> result = RunFunction(
RunFunction(new QuickUnlockPrivateGetCredentialRequirementsFunction(), new extensions::QuickUnlockPrivateGetCredentialRequirementsFunction(),
std::move(params)); std::move(params));
CredentialRequirements function_result; CredentialRequirements function_result;
EXPECT_TRUE(CredentialRequirements::Populate(*result, &function_result)); EXPECT_TRUE(CredentialRequirements::Populate(*result, &function_result));
...@@ -394,7 +391,7 @@ class QuickUnlockPrivateUnitTest ...@@ -394,7 +391,7 @@ class QuickUnlockPrivateUnitTest
const CredentialList& passwords) { const CredentialList& passwords) {
std::unique_ptr<base::ListValue> params = std::unique_ptr<base::ListValue> params =
GetSetModesParams(token_, modes, passwords); GetSetModesParams(token_, modes, passwords);
auto* func = new QuickUnlockPrivateSetModesFunction(); auto* func = new extensions::QuickUnlockPrivateSetModesFunction();
// Stub out event handling since we are not setting up an event router. // Stub out event handling since we are not setting up an event router.
func->SetModesChangedEventHandlerForTesting(modes_changed_handler_); func->SetModesChangedEventHandlerForTesting(modes_changed_handler_);
...@@ -414,7 +411,7 @@ class QuickUnlockPrivateUnitTest ...@@ -414,7 +411,7 @@ class QuickUnlockPrivateUnitTest
std::string RunSetModesWithInvalidToken() { std::string RunSetModesWithInvalidToken() {
std::unique_ptr<base::ListValue> params = GetSetModesParams( std::unique_ptr<base::ListValue> params = GetSetModesParams(
kInvalidToken, {QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"111111"}); kInvalidToken, {QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"111111"});
auto* func = new QuickUnlockPrivateSetModesFunction(); auto* func = new extensions::QuickUnlockPrivateSetModesFunction();
// Stub out event handling since we are not setting up an event router. // Stub out event handling since we are not setting up an event router.
func->SetModesChangedEventHandlerForTesting(modes_changed_handler_); func->SetModesChangedEventHandlerForTesting(modes_changed_handler_);
...@@ -424,10 +421,11 @@ class QuickUnlockPrivateUnitTest ...@@ -424,10 +421,11 @@ class QuickUnlockPrivateUnitTest
} }
std::string SetModesWithError(const std::string& args) { std::string SetModesWithError(const std::string& args) {
auto* func = new QuickUnlockPrivateSetModesFunction(); auto* func = new extensions::QuickUnlockPrivateSetModesFunction();
func->SetModesChangedEventHandlerForTesting(base::DoNothing()); func->SetModesChangedEventHandlerForTesting(base::DoNothing());
return api_test_utils::RunFunctionAndReturnError(func, args, profile()); return extensions::api_test_utils::RunFunctionAndReturnError(func, args,
profile());
} }
std::string token() { return token_; } std::string token() { return token_; }
...@@ -474,11 +472,12 @@ class QuickUnlockPrivateUnitTest ...@@ -474,11 +472,12 @@ class QuickUnlockPrivateUnitTest
scoped_refptr<ExtensionFunction> func, scoped_refptr<ExtensionFunction> func,
std::unique_ptr<base::ListValue> params) { std::unique_ptr<base::ListValue> params) {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
std::unique_ptr<base::Value> result = std::unique_ptr<base::Value> result = extensions::api_test_utils::
api_test_utils::RunFunctionWithDelegateAndReturnSingleResult( RunFunctionWithDelegateAndReturnSingleResult(
func, std::move(params), profile(), func, std::move(params), profile(),
std::make_unique<ExtensionFunctionDispatcher>(profile()), std::make_unique<extensions::ExtensionFunctionDispatcher>(
api_test_utils::NONE); profile()),
extensions::api_test_utils::NONE);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
return result; return result;
} }
...@@ -488,10 +487,11 @@ class QuickUnlockPrivateUnitTest ...@@ -488,10 +487,11 @@ class QuickUnlockPrivateUnitTest
scoped_refptr<ExtensionFunction> func, scoped_refptr<ExtensionFunction> func,
std::unique_ptr<base::ListValue> params) { std::unique_ptr<base::ListValue> params) {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
std::unique_ptr<ExtensionFunctionDispatcher> dispatcher( auto dispatcher =
new ExtensionFunctionDispatcher(profile())); std::make_unique<extensions::ExtensionFunctionDispatcher>(profile());
api_test_utils::RunFunction(func.get(), std::move(params), profile(), extensions::api_test_utils::RunFunction(func.get(), std::move(params),
std::move(dispatcher), api_test_utils::NONE); profile(), std::move(dispatcher),
extensions::api_test_utils::NONE);
EXPECT_TRUE(func->GetResultList()->empty()); EXPECT_TRUE(func->GetResultList()->empty());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
return func->GetError(); return func->GetError();
...@@ -507,7 +507,7 @@ class QuickUnlockPrivateUnitTest ...@@ -507,7 +507,7 @@ class QuickUnlockPrivateUnitTest
FakeChromeUserManager* fake_user_manager_ = nullptr; FakeChromeUserManager* fake_user_manager_ = nullptr;
std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_; std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_;
QuickUnlockPrivateSetModesFunction::ModesChangedEventHandler extensions::QuickUnlockPrivateSetModesFunction::ModesChangedEventHandler
modes_changed_handler_; modes_changed_handler_;
bool expect_modes_changed_ = false; bool expect_modes_changed_ = false;
chromeos::UserContext auth_token_user_context_; chromeos::UserContext auth_token_user_context_;
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include "ui/base/test/ui_controls.h" #include "ui/base/test/ui_controls.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
using namespace net::test_server;
namespace chromeos { namespace chromeos {
class OobeTest : public OobeBaseTest { class OobeTest : public OobeBaseTest {
......
...@@ -116,12 +116,6 @@ ...@@ -116,12 +116,6 @@
namespace em = enterprise_management; namespace em = enterprise_management;
using net::test_server::BasicHttpResponse;
using net::test_server::HttpRequest;
using net::test_server::HttpResponse;
using testing::_;
using testing::Return;
namespace chromeos { namespace chromeos {
namespace { namespace {
...@@ -181,10 +175,11 @@ class FakeSamlIdp { ...@@ -181,10 +175,11 @@ class FakeSamlIdp {
void SetCookieValue(const std::string& cookie_value); void SetCookieValue(const std::string& cookie_value);
void SetSamlResponseFile(const std::string& xml_file); void SetSamlResponseFile(const std::string& xml_file);
std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request); std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
const net::test_server::HttpRequest& request);
private: private:
std::unique_ptr<HttpResponse> BuildHTMLResponse( std::unique_ptr<net::test_server::HttpResponse> BuildHTMLResponse(
const std::string& html_template, const std::string& html_template,
const std::string& relay_state, const std::string& relay_state,
const std::string& next_path); const std::string& next_path);
...@@ -248,8 +243,8 @@ void FakeSamlIdp::SetCookieValue(const std::string& cookie_value) { ...@@ -248,8 +243,8 @@ void FakeSamlIdp::SetCookieValue(const std::string& cookie_value) {
cookie_value_ = cookie_value; cookie_value_ = cookie_value;
} }
std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest( std::unique_ptr<net::test_server::HttpResponse> FakeSamlIdp::HandleRequest(
const HttpRequest& request) { const net::test_server::HttpRequest& request) {
// The scheme and host of the URL is actually not important but required to // The scheme and host of the URL is actually not important but required to
// get a valid GURL in order to parse |request.relative_url|. // get a valid GURL in order to parse |request.relative_url|.
GURL request_url = GURL("http://localhost").Resolve(request.relative_url); GURL request_url = GURL("http://localhost").Resolve(request.relative_url);
...@@ -264,7 +259,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest( ...@@ -264,7 +259,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest(
if (request_path != login_auth_path_) { if (request_path != login_auth_path_) {
// Request not understood. // Request not understood.
return std::unique_ptr<HttpResponse>(); return nullptr;
} }
std::string relay_state; std::string relay_state;
...@@ -281,7 +276,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest( ...@@ -281,7 +276,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest(
redirect_url = redirect_url =
net::AppendQueryParameter(redirect_url, kRelayState, relay_state); net::AppendQueryParameter(redirect_url, kRelayState, relay_state);
std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); auto http_response = std::make_unique<net::test_server::BasicHttpResponse>();
http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
http_response->AddCustomHeader("Location", redirect_url.spec()); http_response->AddCustomHeader("Location", redirect_url.spec());
http_response->AddCustomHeader( http_response->AddCustomHeader(
...@@ -289,7 +284,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest( ...@@ -289,7 +284,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::HandleRequest(
return std::move(http_response); return std::move(http_response);
} }
std::unique_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse( std::unique_ptr<net::test_server::HttpResponse> FakeSamlIdp::BuildHTMLResponse(
const std::string& html_template, const std::string& html_template,
const std::string& relay_state, const std::string& relay_state,
const std::string& next_path) { const std::string& next_path) {
...@@ -300,7 +295,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse( ...@@ -300,7 +295,7 @@ std::unique_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse(
base::ReplaceSubstringsAfterOffset(&response_html, 0, "$Refresh", base::ReplaceSubstringsAfterOffset(&response_html, 0, "$Refresh",
refresh_url_.spec()); refresh_url_.spec());
std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); auto http_response = std::make_unique<net::test_server::BasicHttpResponse>();
http_response->set_code(net::HTTP_OK); http_response->set_code(net::HTTP_OK);
http_response->set_content(response_html); http_response->set_content(response_html);
http_response->set_content_type("text/html"); http_response->set_content_type("text/html");
...@@ -866,9 +861,8 @@ void SAMLEnrollmentTest::StartSamlAndWaitForIdpPageLoad( ...@@ -866,9 +861,8 @@ void SAMLEnrollmentTest::StartSamlAndWaitForIdpPageLoad(
} }
guest_view::TestGuestViewManager* SAMLEnrollmentTest::GetGuestViewManager() { guest_view::TestGuestViewManager* SAMLEnrollmentTest::GetGuestViewManager() {
using namespace guest_view; return static_cast<guest_view::TestGuestViewManager*>(
return static_cast<TestGuestViewManager*>( guest_view::TestGuestViewManager::FromBrowserContext(
TestGuestViewManager::FromBrowserContext(
ProfileHelper::GetSigninProfile())); ProfileHelper::GetSigninProfile()));
} }
...@@ -989,8 +983,8 @@ void SAMLPolicyTest::SetUpInProcessBrowserTestFixture() { ...@@ -989,8 +983,8 @@ void SAMLPolicyTest::SetUpInProcessBrowserTestFixture() {
&test_helper_, device_affiliation_ids))); &test_helper_, device_affiliation_ids)));
// Initialize user policy. // Initialize user policy.
EXPECT_CALL(provider_, IsInitializationComplete(_)) EXPECT_CALL(provider_, IsInitializationComplete(testing::_))
.WillRepeatedly(Return(true)); .WillRepeatedly(testing::Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
} }
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
using namespace testing;
namespace chromeos { namespace chromeos {
class UserAddingScreenTest : public LoginManagerTest, class UserAddingScreenTest : public LoginManagerTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment