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

Side by Side Diff: ash/system/network/network_icon_unittest.cc

Issue 2819303002: Changed wifi arcs to mobile bars for Tether network. (Closed)
Patch Set: khorimoto@ comments Created 3 years, 7 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 2017 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/system/network/network_icon.h"
6
7 #include "ash/test/ash_test_base.h"
8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h"
10 #include "chromeos/network/network_handler.h"
11 #include "chromeos/network/network_state.h"
12 #include "chromeos/network/tether_constants.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
15 #include "ui/gfx/image/image_unittest_util.h"
16
17 namespace ash {
18
19 namespace network_icon {
20
21 class NetworkIconTest : public test::AshTestBase {
22 public:
23 NetworkIconTest() {}
24 ~NetworkIconTest() override {}
25
26 void SetUp() override {
27 test::AshTestBase::SetUp();
28 chromeos::NetworkHandler::Initialize();
29
30 tether_network =
31 base::MakeUnique<chromeos::NetworkState>("tetherNetworkPath");
32 tether_network->set_type(chromeos::kTypeTether);
33
34 wifi_network = base::MakeUnique<chromeos::NetworkState>("wifiServicePath");
35 wifi_network->set_type(shill::kTypeWifi);
36
37 cellular_network =
38 base::MakeUnique<chromeos::NetworkState>("cellularServicePath");
39 cellular_network->set_type(shill::kTypeCellular);
40
41 wifi_tether_network =
42 base::MakeUnique<chromeos::NetworkState>("wifiTetherServicePath");
43 wifi_tether_network->set_type(shill::kTypeWifi);
44 wifi_tether_network.get()->set_tether_guid("tetherNetworkGuid");
45 }
46
47 void TearDown() override {
48 PurgeNetworkIconCache();
49 chromeos::NetworkHandler::Shutdown();
50 test::AshTestBase::TearDown();
51 }
52
53 gfx::Image ImageForNetwork(chromeos::NetworkState* network) {
54 gfx::ImageSkia image_skia = GetImageForNetwork(network, icon_type);
55 return gfx::Image(image_skia);
56 }
57
58 // The icon for a Tether network should be the same as one for a cellular
59 // network. The icon for a Tether network should be different from one for a
60 // Wi-Fi network. The icon for a cellular network should be different from one
61 // for a Wi-Fi network. The icon for a Tether network should be the same as
62 // one for a Wi-Fi network with an associated Tether guid.
63 void GetAndCompareImagesByNetworkType() {
64 gfx::Image tether_image = ImageForNetwork(tether_network.get());
65 gfx::Image wifi_image = ImageForNetwork(wifi_network.get());
66 gfx::Image cellular_image = ImageForNetwork(cellular_network.get());
67 gfx::Image wifi_tether_image = ImageForNetwork(wifi_tether_network.get());
68
69 EXPECT_FALSE(gfx::test::AreImagesEqual(tether_image, wifi_image));
70 EXPECT_FALSE(gfx::test::AreImagesEqual(cellular_image, wifi_image));
71 EXPECT_TRUE(gfx::test::AreImagesEqual(tether_image, cellular_image));
72
73 EXPECT_TRUE(gfx::test::AreImagesEqual(tether_image, wifi_tether_image));
74 }
75
76 IconType icon_type = ICON_TYPE_TRAY;
77
78 std::unique_ptr<chromeos::NetworkState> tether_network;
79 std::unique_ptr<chromeos::NetworkState> wifi_network;
80 std::unique_ptr<chromeos::NetworkState> cellular_network;
81 // A network whose type is shill::kTypeWifi, but which is associated with
82 // a Tether network via its tether_guid
Kyle Horimoto 2017/05/03 22:47:28 nit: Don't refer to private types in a description
lesliewatkins 2017/05/04 01:40:16 Done.
83 std::unique_ptr<chromeos::NetworkState> wifi_tether_network;
84
85 private:
86 DISALLOW_COPY_AND_ASSIGN(NetworkIconTest);
87 };
88
89 // This tests that the correct icons are being generated for the correct
90 // networks by pairwise comparison of three different network types, verifying
91 // that the Tether and cellular icon are the same, Tether and Wi-Fi icons are
92 // different, and cellular and Wi-Fi icons are different. Additionaly, it
93 // verifies that the Tether network and Wi-Fi network with associated Tether
94 // guid are treated the same for purposes of icon display
95 TEST_F(NetworkIconTest, CompareImagesByNetworkType_NotVisible) {
96 GetAndCompareImagesByNetworkType();
97 }
98
99 TEST_F(NetworkIconTest, CompareImagesByNetworkType_Connecting) {
100 tether_network->set_visible(true);
101 tether_network->set_connection_state(shill::kStateAssociation);
102
103 wifi_network->set_visible(true);
104 wifi_network->set_connection_state(shill::kStateAssociation);
105
106 cellular_network->set_visible(true);
107 cellular_network->set_connection_state(shill::kStateAssociation);
108
109 wifi_tether_network->set_visible(true);
110 wifi_tether_network->set_connection_state(shill::kStateAssociation);
111
112 GetAndCompareImagesByNetworkType();
113 }
114
115 TEST_F(NetworkIconTest, CompareImagesByNetworkType_Connected) {
116 tether_network->set_visible(true);
117 tether_network->set_connection_state(shill::kStateOnline);
118
119 wifi_network->set_visible(true);
120 wifi_network->set_connection_state(shill::kStateOnline);
121
122 cellular_network->set_visible(true);
123 cellular_network->set_connection_state(shill::kStateOnline);
124
125 wifi_tether_network->set_visible(true);
126 wifi_tether_network->set_connection_state(shill::kStateOnline);
127
128 GetAndCompareImagesByNetworkType();
129 }
130
131 } // namespace network_icon
132
133 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698