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

Unified Diff: chromeos/dbus/fake_auth_policy_client_unittest.cc

Issue 2794493002: Add AuthPolicyLoginHelper (Closed)
Patch Set: Switch to OnceCallback+Update on comments+rebase Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/fake_auth_policy_client_unittest.cc
diff --git a/chromeos/dbus/fake_auth_policy_client_unittest.cc b/chromeos/dbus/fake_auth_policy_client_unittest.cc
index e220238e18e8d2c30796b8f74b9fb910f1adb156..c8e6cb9dc797612784381b04ee9bc97635189435 100644
--- a/chromeos/dbus/fake_auth_policy_client_unittest.cc
+++ b/chromeos/dbus/fake_auth_policy_client_unittest.cc
@@ -5,6 +5,8 @@
#include "chromeos/dbus/fake_auth_policy_client.h"
#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "components/signin/core/account_id/account_id.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -16,9 +18,16 @@ const char kCorrectUserName[] = "user@realm.com";
} // namespace
-// Tests parsing machine name.
-TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseMachineName) {
+class FakeAuthPolicyClientTest : public ::testing::Test {
+ protected:
FakeAuthPolicyClient client;
xiyuan 2017/04/07 15:04:24 client -> client_ And I would prefer to put this
Roman Sorokin (ftl) 2017/04/10 16:09:00 Done.
+
+ private:
+ base::MessageLoop loop;
xiyuan 2017/04/07 15:04:24 loop -> loop_
Roman Sorokin (ftl) 2017/04/10 16:09:00 Done.
+};
xiyuan 2017/04/07 15:04:24 nit: DISALLOW_COPY_AND_ASSIGN
Roman Sorokin (ftl) 2017/04/10 16:09:00 Done.
+
+// Tests parsing machine name.
+TEST_F(FakeAuthPolicyClientTest, JoinAdDomain_ParseMachineName) {
client.set_started(true);
client.JoinAdDomain("correct_length1", kCorrectUserName, /* password_fd */ -1,
base::Bind([](authpolicy::ErrorType error) {
@@ -41,11 +50,12 @@ TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseMachineName) {
base::Bind([](authpolicy::ErrorType error) {
EXPECT_EQ(authpolicy::ERROR_BAD_MACHINE_NAME, error);
}));
+
+ base::RunLoop().RunUntilIdle();
}
// Tests parsing user name.
-TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseUPN) {
- FakeAuthPolicyClient client;
+TEST_F(FakeAuthPolicyClientTest, JoinAdDomain_ParseUPN) {
client.set_started(true);
client.JoinAdDomain(kCorrectMachineName, "user@realm.com",
/* password_fd */ -1,
@@ -73,11 +83,12 @@ TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseUPN) {
base::Bind([](authpolicy::ErrorType error) {
EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
}));
+
+ base::RunLoop().RunUntilIdle();
}
// Tests calls to not started authpolicyd fails.
-TEST(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) {
- FakeAuthPolicyClient client;
+TEST_F(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) {
client.JoinAdDomain(kCorrectMachineName, kCorrectUserName,
/* password_fd */ -1,
base::Bind([](authpolicy::ErrorType error) {
@@ -94,6 +105,8 @@ TEST(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) {
client.RefreshUserPolicy(
AccountId::FromUserEmail(kCorrectUserName),
base::Bind([](bool success) { EXPECT_FALSE(success); }));
+
+ base::RunLoop().RunUntilIdle();
}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698