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

Side by Side Diff: ash/common/system/chromeos/network/vpn_delegate_unittest.cc

Issue 2513673004: Reland: chromeos: Convert ash VPNDelegate interface to mojo (Closed)
Patch Set: fix manifest for reland Created 4 years, 1 month 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 2016 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 "ash/common/system/chromeos/network/vpn_delegate.h"
6
7 #include <algorithm>
8 #include <vector>
9
10 #include "base/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace ash {
14
15 namespace {
16
17 class TestVpnDelegate : public VPNDelegate {
18 public:
19 TestVpnDelegate() {}
20 ~TestVpnDelegate() override {}
21
22 // VPNDelegate:
23 void ShowAddPage(const std::string& extension_id) override {}
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(TestVpnDelegate);
27 };
28
29 } // namespace
30
31 using VpnDelegateTest = testing::Test;
32
33 TEST_F(VpnDelegateTest, BuiltInProvider) {
34 TestVpnDelegate delegate;
35
36 // The VPN list should only contain the built-in provider.
37 ASSERT_EQ(1u, delegate.vpn_providers().size());
38 VPNProvider provider = delegate.vpn_providers()[0];
39 EXPECT_FALSE(provider.third_party);
40 EXPECT_TRUE(provider.extension_id.empty());
41 }
42
43 TEST_F(VpnDelegateTest, ThirdPartyProviders) {
44 TestVpnDelegate delegate;
45
46 // The VPN list should only contain the built-in provider.
47 EXPECT_EQ(1u, delegate.vpn_providers().size());
48
49 // Add some third party (extension-backed) providers.
50 VPNProvider provider1("extension_id1", "name1");
51 VPNProvider provider2("extension_id2", "name2");
52 std::vector<VPNProvider> third_party_providers = {provider1, provider2};
53 delegate.SetThirdPartyVpnProviders(third_party_providers);
54
55 // List contains the extension-backed providers. Order doesn't matter.
56 std::vector<VPNProvider> providers = delegate.vpn_providers();
57 EXPECT_EQ(3u, providers.size());
58 EXPECT_EQ(1u, std::count(providers.begin(), providers.end(), provider1));
59 EXPECT_EQ(1u, std::count(providers.begin(), providers.end(), provider2));
60 }
61
62 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/vpn_delegate.cc ('k') | ash/common/system/chromeos/network/vpn_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698