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

Side by Side Diff: chrome/browser/chromeos/status/data_promo_notification_unittest.cc

Issue 2342523002: Forcibly clear worker ref counts on shutdown. (Closed)
Patch Set: rebase Created 4 years, 2 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chromeos/status/data_promo_notification.h" 5 #include "chrome/browser/chromeos/status/data_promo_notification.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
12 #include "chrome/test/base/testing_browser_process.h" 12 #include "chrome/test/base/testing_browser_process.h"
13 #include "chrome/test/base/testing_profile_manager.h" 13 #include "chrome/test/base/testing_profile_manager.h"
14 #include "chromeos/chromeos_switches.h" 14 #include "chromeos/chromeos_switches.h"
15 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/dbus/shill_device_client.h" 16 #include "chromeos/dbus/shill_device_client.h"
17 #include "chromeos/dbus/shill_service_client.h" 17 #include "chromeos/dbus/shill_service_client.h"
18 #include "chromeos/login/login_state.h" 18 #include "chromeos/login/login_state.h"
19 #include "chromeos/network/network_state_handler.h" 19 #include "chromeos/network/network_state_handler.h"
20 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "testing/platform_test.h" 21 #include "testing/platform_test.h"
21 #include "third_party/cros_system_api/dbus/service_constants.h" 22 #include "third_party/cros_system_api/dbus/service_constants.h"
22 #include "ui/chromeos/network/network_connect.h" 23 #include "ui/chromeos/network/network_connect.h"
23 #include "ui/message_center/message_center.h" 24 #include "ui/message_center/message_center.h"
24 25
25 namespace { 26 namespace {
26 27
27 const char kCellularDevicePath[] = "/device/stub_cellular_device1"; 28 const char kCellularDevicePath[] = "/device/stub_cellular_device1";
28 const char kCellularServicePath[] = "/service/cellular1"; 29 const char kCellularServicePath[] = "/service/cellular1";
29 const char kNotificationId[] = "chrome://settings/internet/data_saver"; 30 const char kNotificationId[] = "chrome://settings/internet/data_saver";
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 "cellular1" /* name */, shill::kTypeCellular, 129 "cellular1" /* name */, shill::kTypeCellular,
129 "activated", true /* visible */); 130 "activated", true /* visible */);
130 service_test->SetServiceProperty( 131 service_test->SetServiceProperty(
131 kCellularServicePath, shill::kActivationStateProperty, 132 kCellularServicePath, shill::kActivationStateProperty,
132 base::StringValue(shill::kActivationStateActivated)); 133 base::StringValue(shill::kActivationStateActivated));
133 service_test->SetServiceProperty(kCellularServicePath, 134 service_test->SetServiceProperty(kCellularServicePath,
134 shill::kConnectableProperty, 135 shill::kConnectableProperty,
135 base::FundamentalValue(true)); 136 base::FundamentalValue(true));
136 } 137 }
137 138
139 content::TestBrowserThreadBundle thread_bundle_;
138 std::unique_ptr<DataPromoNotification> data_promo_notification_; 140 std::unique_ptr<DataPromoNotification> data_promo_notification_;
139 std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_; 141 std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_;
140 std::unique_ptr<ScopedUserManagerEnabler> user_manager_enabler_; 142 std::unique_ptr<ScopedUserManagerEnabler> user_manager_enabler_;
141 std::unique_ptr<TestingProfileManager> profile_manager_; 143 std::unique_ptr<TestingProfileManager> profile_manager_;
142 base::MessageLoop message_loop_;
143 144
144 private: 145 private:
145 DISALLOW_COPY_AND_ASSIGN(DataPromoNotificationTest); 146 DISALLOW_COPY_AND_ASSIGN(DataPromoNotificationTest);
146 }; 147 };
147 148
148 TEST_F(DataPromoNotificationTest, DataSaverNotification) { 149 TEST_F(DataPromoNotificationTest, DataSaverNotification) {
149 message_center::MessageCenter* message_center = 150 message_center::MessageCenter* message_center =
150 message_center::MessageCenter::Get(); 151 message_center::MessageCenter::Get();
151 152
152 // Network setup shouldn't be enough to activate notification. 153 // Network setup shouldn't be enough to activate notification.
153 EXPECT_FALSE(message_center->FindVisibleNotificationById(kNotificationId)); 154 EXPECT_FALSE(message_center->FindVisibleNotificationById(kNotificationId));
154 155
155 ui::NetworkConnect::Get()->ConnectToNetwork(kCellularServicePath); 156 ui::NetworkConnect::Get()->ConnectToNetwork(kCellularServicePath);
156 base::RunLoop().RunUntilIdle(); 157 base::RunLoop().RunUntilIdle();
157 // Connecting to cellular network (which here makes it the default network) 158 // Connecting to cellular network (which here makes it the default network)
158 // should trigger the Data Saver notification. 159 // should trigger the Data Saver notification.
159 EXPECT_TRUE(message_center->FindVisibleNotificationById(kNotificationId)); 160 EXPECT_TRUE(message_center->FindVisibleNotificationById(kNotificationId));
160 } 161 }
161 162
162 } // namespace test 163 } // namespace test
163 } // namespace chromeos 164 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698