Index: remoting/host/it2me/it2me_host_unittest.cc |
diff --git a/remoting/host/it2me/it2me_host_unittest.cc b/remoting/host/it2me/it2me_host_unittest.cc |
index 38cafc4f50e3e2cd3422416805f054458125c91a..3d8b0e97d0b5f4df01cf756593eea023958510d9 100644 |
--- a/remoting/host/it2me/it2me_host_unittest.cc |
+++ b/remoting/host/it2me/it2me_host_unittest.cc |
@@ -19,7 +19,6 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/run_loop.h" |
#include "base/threading/thread_task_runner_handle.h" |
-#include "components/policy/core/common/fake_async_policy_loader.h" |
#include "components/policy/policy_constants.h" |
#include "remoting/base/auto_thread_task_runner.h" |
#include "remoting/host/chromoting_host_context.h" |
@@ -169,9 +168,6 @@ class It2MeHostTest : public testing::Test, public It2MeHost::Observer { |
scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
scoped_refptr<It2MeHost> it2me_host_; |
- // The FakeAsyncPolicyLoader is owned by it2me_host_, but we retain a raw |
- // pointer so we can control the policy contents. |
- policy::FakeAsyncPolicyLoader* policy_loader_ = nullptr; |
base::WeakPtrFactory<It2MeHostTest> weak_factory_; |
@@ -195,12 +191,8 @@ void It2MeHostTest::SetUp() { |
std::unique_ptr<FakeIt2MeDialogFactory> dialog_factory( |
new FakeIt2MeDialogFactory()); |
dialog_factory_ = dialog_factory.get(); |
- policy_loader_ = |
- new policy::FakeAsyncPolicyLoader(base::ThreadTaskRunnerHandle::Get()); |
it2me_host_ = new It2MeHost( |
std::move(host_context), |
- PolicyWatcher::CreateFromPolicyLoaderForTesting( |
- base::WrapUnique(policy_loader_)), |
std::move(dialog_factory), weak_factory_.GetWeakPtr(), |
base::WrapUnique( |
new FakeSignalStrategy(SignalingAddress("fake_local_jid"))), |
@@ -227,17 +219,11 @@ void It2MeHostTest::OnValidationComplete(const base::Closure& resume_callback, |
void It2MeHostTest::SetPolicies( |
std::initializer_list<std::pair<base::StringPiece, const base::Value&>> |
policies) { |
- policy::PolicyBundle bundle; |
- policy::PolicyMap& map = bundle.Get( |
- policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())); |
+ std::unique_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue); |
rkjnsn
2017/04/28 21:15:36
nit: I think MakeUnique is more readable:
auto dic
Jamie
2017/04/28 22:41:09
Done.
|
for (const auto& policy : policies) { |
- map.Set(policy.first.as_string(), policy::POLICY_LEVEL_MANDATORY, |
- policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM, |
- policy.second.CreateDeepCopy(), nullptr); |
+ dictionary->Set(policy.first, policy.second.CreateDeepCopy()); |
} |
- policy_loader_->SetPolicies(bundle); |
- policy_loader_->PostReloadOnBackgroundThread(true); |
- base::RunLoop().RunUntilIdle(); |
+ it2me_host_->OnPolicyUpdate(std::move(dictionary)); |
rkjnsn
2017/04/28 21:15:36
Note that this will bypass normalization and depre
joedow
2017/04/28 21:46:32
Using the old system (PolicyWatcher + FakeAsyncPol
Jamie
2017/04/28 22:41:09
The tests hang without a call to SetPolicies (I th
Jamie
2017/04/28 22:41:09
I'll hold off landing until that's in then. I thin
rkjnsn
2017/05/02 19:19:12
It2MeHost will indeed wait for OnPolicyUpdate to b
Jamie
2017/05/02 22:07:56
I think that's mixing up responsibilities too much
rkjnsn
2017/05/02 23:20:19
I mostly agree. My main concern is here was the di
rkjnsn
2017/05/02 23:27:19
their*
Jamie
2017/05/02 23:49:03
That's a good point. I was going to argue that It2
Jamie
2017/05/03 20:41:04
I've taken this approach in the most recent iterat
|
} |
void It2MeHostTest::StartupHostStateHelper(const base::Closure& quit_closure) { |
@@ -255,6 +241,7 @@ void It2MeHostTest::StartupHostStateHelper(const base::Closure& quit_closure) { |
} |
void It2MeHostTest::StartHost() { |
+ SetPolicies({}); // For tests that don't set any policies |
it2me_host_->Connect(); |
base::RunLoop run_loop; |