OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/views/certificate_selector.h" |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/browser/ui/views/certificate_selector.h" | |
12 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
13 #include "chrome/test/base/interactive_test_utils.h" | 15 #include "chrome/test/base/interactive_test_utils.h" |
14 #include "content/public/test/browser_test_utils.h" | 16 #include "content/public/test/browser_test_utils.h" |
15 #include "net/base/test_data_directory.h" | 17 #include "net/base/test_data_directory.h" |
16 #include "net/cert/x509_certificate.h" | 18 #include "net/cert/x509_certificate.h" |
17 #include "net/test/cert_test_util.h" | 19 #include "net/test/cert_test_util.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/views/controls/label.h" | 21 #include "ui/views/controls/label.h" |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 class TestCertificateSelector : public chrome::CertificateSelector { | 25 class TestCertificateSelector : public chrome::CertificateSelector { |
24 public: | 26 public: |
25 TestCertificateSelector(const net::CertificateList& certificates, | 27 TestCertificateSelector(const net::CertificateList& certificates, |
26 content::WebContents* web_contents) | 28 content::WebContents* web_contents) |
27 : CertificateSelector(certificates, web_contents) {} | 29 : CertificateSelector(certificates, web_contents) {} |
28 | 30 |
29 ~TestCertificateSelector() override { | 31 ~TestCertificateSelector() override { |
30 if (!on_destroy_.is_null()) | 32 if (!on_destroy_.is_null()) |
31 on_destroy_.Run(); | 33 on_destroy_.Run(); |
32 } | 34 } |
33 | 35 |
34 void Init() { | 36 void Init() { |
35 InitWithText(make_scoped_ptr( | 37 InitWithText(base::WrapUnique( |
36 new views::Label(base::ASCIIToUTF16("some arbitrary text")))); | 38 new views::Label(base::ASCIIToUTF16("some arbitrary text")))); |
37 } | 39 } |
38 | 40 |
39 bool Accept() override { | 41 bool Accept() override { |
40 if (accepted_) | 42 if (accepted_) |
41 *accepted_ = true; | 43 *accepted_ = true; |
42 return CertificateSelector::Accept(); | 44 return CertificateSelector::Accept(); |
43 } | 45 } |
44 | 46 |
45 bool Cancel() override { | 47 bool Cancel() override { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 selector_->OnDoubleClick(); | 124 selector_->OnDoubleClick(); |
123 | 125 |
124 // Wait for the dialog to be closed and destroyed. | 126 // Wait for the dialog to be closed and destroyed. |
125 loop.Run(); | 127 loop.Run(); |
126 | 128 |
127 // Closing the dialog through a double click must call only the Accept() | 129 // Closing the dialog through a double click must call only the Accept() |
128 // function and not Cancel(). | 130 // function and not Cancel(). |
129 EXPECT_TRUE(accepted); | 131 EXPECT_TRUE(accepted); |
130 EXPECT_FALSE(canceled); | 132 EXPECT_FALSE(canceled); |
131 } | 133 } |
OLD | NEW |