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

Side by Side Diff: components/password_manager/core/browser/password_reuse_detection_manager_unittest.cc

Issue 2798963003: Use ScopedTaskEnvironment instead of MessageLoop in components unit tests. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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 "components/password_manager/core/browser/password_reuse_detection_mana ger.h" 5 #include "components/password_manager/core/browser/password_reuse_detection_mana ger.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/scoped_task_environment.h"
9 #include "components/password_manager/core/browser/mock_password_store.h" 10 #include "components/password_manager/core/browser/mock_password_store.h"
10 #include "components/password_manager/core/browser/stub_password_manager_client. h" 11 #include "components/password_manager/core/browser/stub_password_manager_client. h"
11 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 using base::ASCIIToUTF16; 16 using base::ASCIIToUTF16;
16 using testing::AnyNumber; 17 using testing::AnyNumber;
17 using testing::_; 18 using testing::_;
18 19
(...skipping 22 matching lines...) Expand all
41 CHECK(store_->Init(syncer::SyncableService::StartSyncFlare())); 42 CHECK(store_->Init(syncer::SyncableService::StartSyncFlare()));
42 } 43 }
43 void TearDown() override { 44 void TearDown() override {
44 store_->ShutdownOnUIThread(); 45 store_->ShutdownOnUIThread();
45 store_ = nullptr; 46 store_ = nullptr;
46 } 47 }
47 48
48 protected: 49 protected:
49 // It's needed for an initialisation of thread runners that are used in 50 // It's needed for an initialisation of thread runners that are used in
50 // MockPasswordStore. 51 // MockPasswordStore.
51 base::MessageLoop message_loop_; 52 base::test::ScopedTaskEnvironment scoped_task_environment_;
52 MockPasswordManagerClient client_; 53 MockPasswordManagerClient client_;
53 scoped_refptr<MockPasswordStore> store_; 54 scoped_refptr<MockPasswordStore> store_;
54 55
55 DISALLOW_COPY_AND_ASSIGN(PasswordReuseDetectionManagerTest); 56 DISALLOW_COPY_AND_ASSIGN(PasswordReuseDetectionManagerTest);
56 }; 57 };
57 58
58 // Verify that CheckReuse is called on each key pressed event with an argument 59 // Verify that CheckReuse is called on each key pressed event with an argument
59 // equal to the last 30 keystrokes typed after the last main frame navigaion. 60 // equal to the last 30 keystrokes typed after the last main frame navigaion.
60 TEST_F(PasswordReuseDetectionManagerTest, CheckReuseCalled) { 61 TEST_F(PasswordReuseDetectionManagerTest, CheckReuseCalled) {
61 const GURL gurls[] = {GURL("https://www.example.com"), 62 const GURL gurls[] = {GURL("https://www.example.com"),
(...skipping 19 matching lines...) Expand all
81 CheckReuse(expected_input, gurls[test].GetOrigin().spec(), &manager)); 82 CheckReuse(expected_input, gurls[test].GetOrigin().spec(), &manager));
82 manager.OnKeyPressed(input[test].substr(i, 1)); 83 manager.OnKeyPressed(input[test].substr(i, 1));
83 testing::Mock::VerifyAndClearExpectations(store_.get()); 84 testing::Mock::VerifyAndClearExpectations(store_.get());
84 } 85 }
85 } 86 }
86 } 87 }
87 88
88 } // namespace 89 } // namespace
89 90
90 } // namespace password_manager 91 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/omnibox/browser/zero_suggest_provider_unittest.cc ('k') | components/prefs/pref_member_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698