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

Side by Side Diff: remoting/host/it2me/it2me_confirmation_dialog_proxy_unittest.cc

Issue 2310303002: Moving It2Me confirmation prompt into the Validation callback flow (Closed)
Patch Set: Addressing CR Feedback Created 4 years, 3 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 "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" 5 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gmock_mutant.h" 15 #include "testing/gmock_mutant.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 using ::testing::InvokeWithoutArgs; 18 using ::testing::InvokeWithoutArgs;
19 using ::testing::CreateFunctor; 19 using ::testing::CreateFunctor;
20 20
21 namespace remoting { 21 namespace remoting {
22 22
23 namespace {
24 const char kTestEmailAddress[] = "faux_remote_user@chromium_test.com";
25 } // namespace
26
23 class StubIt2MeConfirmationDialog : public It2MeConfirmationDialog { 27 class StubIt2MeConfirmationDialog : public It2MeConfirmationDialog {
24 public: 28 public:
25 explicit StubIt2MeConfirmationDialog( 29 explicit StubIt2MeConfirmationDialog(
26 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 30 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
27 : task_runner_(task_runner) { 31 : task_runner_(task_runner) {
28 } 32 }
29 ~StubIt2MeConfirmationDialog() override { 33 ~StubIt2MeConfirmationDialog() override {
30 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); 34 EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
31 } 35 }
32 36
33 void ReportResult(Result result) { 37 void ReportResult(Result result) {
34 ASSERT_TRUE(task_runner_->BelongsToCurrentThread()); 38 ASSERT_TRUE(task_runner_->BelongsToCurrentThread());
35 callback_.Run(result); 39 callback_.Run(result);
36 } 40 }
37 41
38 MOCK_METHOD0(OnShow, void()); 42 MOCK_METHOD0(OnShow, void());
39 43
40 // It2MeConfirmationDialog implementation. 44 // It2MeConfirmationDialog implementation.
41 void Show(const ResultCallback& callback) override { 45 void Show(const std::string& remote_user_email,
46 const ResultCallback& callback) override {
42 EXPECT_TRUE(callback_.is_null()); 47 EXPECT_TRUE(callback_.is_null());
43 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); 48 EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
49 EXPECT_EQ(remote_user_email.compare(kTestEmailAddress), 0);
44 callback_ = callback; 50 callback_ = callback;
45 OnShow(); 51 OnShow();
46 } 52 }
47 53
48 private: 54 private:
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
50 ResultCallback callback_; 56 ResultCallback callback_;
51 }; 57 };
52 58
53 // Encapsulates a target for It2MeConfirmationDialog::ResultCallback. 59 // Encapsulates a target for It2MeConfirmationDialog::ResultCallback.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 CreateFunctor( 140 CreateFunctor(
135 &StubIt2MeConfirmationDialog::ReportResult, 141 &StubIt2MeConfirmationDialog::ReportResult,
136 base::Unretained(dialog()), 142 base::Unretained(dialog()),
137 It2MeConfirmationDialog::Result::CANCEL))); 143 It2MeConfirmationDialog::Result::CANCEL)));
138 144
139 EXPECT_CALL(callback_target, 145 EXPECT_CALL(callback_target,
140 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL)) 146 OnDialogResult(It2MeConfirmationDialog::Result::CANCEL))
141 .WillOnce( 147 .WillOnce(
142 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit)); 148 InvokeWithoutArgs(this, &It2MeConfirmationDialogProxyTest::Quit));
143 149
144 dialog_proxy()->Show(callback_target.MakeCallback()); 150 dialog_proxy()->Show(kTestEmailAddress, callback_target.MakeCallback());
145 151
146 Run(); 152 Run();
147 } 153 }
148 154
149 } // namespace remoting 155 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_confirmation_dialog_proxy.cc ('k') | remoting/host/it2me/it2me_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698