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

Side by Side Diff: chromeos/network/shill_property_handler_unittest.cc

Issue 1431563005: Handle prohibited technologies in device policy ONC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove dependencies for NetworkHandler in ShillPropertyHandlerTest.ProhibitedTechnologies Created 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/network/shill_property_handler.h" 5 #include "chromeos/network/shill_property_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ASSERT_TRUE(manager_test_); 176 ASSERT_TRUE(manager_test_);
177 device_test_ = 177 device_test_ =
178 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); 178 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
179 ASSERT_TRUE(device_test_); 179 ASSERT_TRUE(device_test_);
180 service_test_ = 180 service_test_ =
181 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); 181 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
182 ASSERT_TRUE(service_test_); 182 ASSERT_TRUE(service_test_);
183 profile_test_ = 183 profile_test_ =
184 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); 184 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
185 ASSERT_TRUE(profile_test_); 185 ASSERT_TRUE(profile_test_);
186 if (!LoginState::IsInitialized())
187 LoginState::Initialize();
186 SetupShillPropertyHandler(); 188 SetupShillPropertyHandler();
187 message_loop_.RunUntilIdle(); 189 message_loop_.RunUntilIdle();
188 } 190 }
189 191
190 void TearDown() override { 192 void TearDown() override {
191 shill_property_handler_.reset(); 193 shill_property_handler_.reset();
192 listener_.reset(); 194 listener_.reset();
193 DBusThreadManager::Shutdown(); 195 DBusThreadManager::Shutdown();
194 } 196 }
195 197
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 AddServiceToProfile(shill::kTypeWifi, kTestServicePath2, true); 496 AddServiceToProfile(shill::kTypeWifi, kTestServicePath2, true);
495 shill_property_handler_->UpdateManagerProperties(); 497 shill_property_handler_->UpdateManagerProperties();
496 message_loop_.RunUntilIdle(); 498 message_loop_.RunUntilIdle();
497 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); 499 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
498 EXPECT_EQ(1, listener_->initial_property_updates( 500 EXPECT_EQ(1, listener_->initial_property_updates(
499 shill::kServiceCompleteListProperty)[kTestServicePath2]); 501 shill::kServiceCompleteListProperty)[kTestServicePath2]);
500 EXPECT_EQ(1, listener_->property_updates( 502 EXPECT_EQ(1, listener_->property_updates(
501 shill::kServiceCompleteListProperty)[kTestServicePath2]); 503 shill::kServiceCompleteListProperty)[kTestServicePath2]);
502 } 504 }
503 505
506 TEST_F(ShillPropertyHandlerTest, ProhibitedTechnologies) {
507 std::vector<std::string> prohibited_technologies;
508 prohibited_technologies.push_back(shill::kTypeEthernet);
509 EXPECT_TRUE(
510 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
511 shill_property_handler_->SetProhibitedTechnologies(
512 prohibited_technologies, network_handler::ErrorCallback());
513 LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_ACTIVE,
514 LoginState::LOGGED_IN_USER_REGULAR);
515 shill_property_handler_->UserPolicyApplied();
516 message_loop_.RunUntilIdle();
517 // Disabled at user session
518 EXPECT_FALSE(
519 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
520
521 // Can not enable it back
522 shill_property_handler_->SetTechnologyEnabled(
523 shill::kTypeEthernet, true, network_handler::ErrorCallback());
524 message_loop_.RunUntilIdle();
525 EXPECT_FALSE(
526 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
527
528 // Can enable it back after policy changes
529 prohibited_technologies.clear();
530 shill_property_handler_->SetProhibitedTechnologies(
531 prohibited_technologies, network_handler::ErrorCallback());
532 shill_property_handler_->SetTechnologyEnabled(
533 shill::kTypeEthernet, true, network_handler::ErrorCallback());
534 message_loop_.RunUntilIdle();
535 EXPECT_TRUE(
536 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
537 }
538
504 } // namespace chromeos 539 } // namespace chromeos
OLDNEW
« chromeos/network/shill_property_handler.h ('K') | « chromeos/network/shill_property_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698