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

Side by Side Diff: chrome/browser/ui/views/certificate_selector_browsertest.cc

Issue 932553002: Refactor SSLClientCertificateSelector for reuse with platformKeys API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_perms
Patch Set: Addressed comments, some cleanup like const-ness, CHECKs, logging, includes, ... Created 5 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/files/file_path.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/views/certificate_selector.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/interactive_test_utils.h"
13 #include "content/public/test/browser_test_utils.h"
14 #include "net/base/test_data_directory.h"
15 #include "net/cert/x509_certificate.h"
16 #include "net/test/cert_test_util.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18
19 namespace {
20
21 class CertificateSelectorTest : public InProcessBrowserTest {
22 public:
23 void SetUpInProcessBrowserTestFixture() override {
24 client_1_ =
25 net::ImportCertFromFile(net::GetTestCertsDirectory(), "client_1.pem");
26 ASSERT_TRUE(client_1_);
msw 2015/02/19 19:53:53 nit: ASSERT_NE to nullptr; ditto below.
pneubeck (no reviews) 2015/02/19 20:43:49 Done.
27
28 client_2_ =
29 net::ImportCertFromFile(net::GetTestCertsDirectory(), "client_2.pem");
30 ASSERT_TRUE(client_2_);
31 }
32
33 void SetUpOnMainThread() override {
34 ASSERT_TRUE(content::WaitForLoadStop(
35 browser()->tab_strip_model()->GetActiveWebContents()));
36
37 net::CertificateList certificates;
38 certificates.push_back(client_1_);
39 certificates.push_back(client_2_);
40
41 selector_ = new chrome::CertificateSelector(
42 certificates, browser()->tab_strip_model()->GetActiveWebContents());
43 selector_->Init(base::ASCIIToUTF16("some arbitrary text"));
44 }
45
46 protected:
47 scoped_refptr<net::X509Certificate> client_1_;
48 scoped_refptr<net::X509Certificate> client_2_;
49
50 // The selector will be deleted when the browser is shutdown.
msw 2015/02/19 19:53:53 Perhaps explicitly close the |selector_| dialog in
pneubeck (no reviews) 2015/02/19 20:43:49 Done.
51 chrome::CertificateSelector* selector_ = nullptr;
msw 2015/02/19 19:53:53 Use the initializer list; don't assign here.
pneubeck (no reviews) 2015/02/19 20:43:49 As I understand the style-guide this is the prefer
msw 2015/02/19 21:03:31 Interesting; I suppose the style has changed since
52 };
53
54 } // namespace
55
56 IN_PROC_BROWSER_TEST_F(CertificateSelectorTest, GetSelectedCert) {
57 EXPECT_EQ(client_1_.get(), selector_->GetSelectedCert());
58 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_DOWN, false,
59 false, false, false));
60 EXPECT_EQ(client_2_.get(), selector_->GetSelectedCert());
61 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_UP, false,
62 false, false, false));
63 EXPECT_EQ(client_1_.get(), selector_->GetSelectedCert());
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698