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

Side by Side Diff: chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 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 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 "\"TrustBits\":[\"Web\"]," 44 "\"TrustBits\":[\"Web\"],"
45 "\"X509\":\"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ" 45 "\"X509\":\"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ"
46 "1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpc" 46 "1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpc"
47 "yBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCB" 47 "yBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCB"
48 "pbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ" 48 "pbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ"
49 "GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" 49 "GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4"
50 "=\"," 50 "=\","
51 "\"GUID\":\"{00f79111-51e0-e6e0-76b3b55450d80a1b}\"}" 51 "\"GUID\":\"{00f79111-51e0-e6e0-76b3b55450d80a1b}\"}"
52 "]}"; 52 "]}";
53 53
54 // Helper class to define the PolicyStringCallback that expects to be called 54 // Helper class to define a PolicyStringCallback which verifies that it was run.
55 // at least once and that expects a given string as parameter. 55 // Wraps a bool initially set to |false| and verifies that it's been set to
56 class PolicyStringRunnable 56 // |true| before destruction.
57 : public arc::ArcPolicyBridge::GetPoliciesCallback::Runnable { 57 class CheckedBoolean {
58 public: 58 public:
59 explicit PolicyStringRunnable(mojo::String expected) 59 CheckedBoolean() {}
60 : expected_(std::move(expected)) {} 60 ~CheckedBoolean() { EXPECT_TRUE(value_); }
61 ~PolicyStringRunnable() override { EXPECT_TRUE(was_run); } 61
62 void Run(const mojo::String& policies) override { 62 void set_value(bool value) { value_ = value; }
63 EXPECT_EQ(expected_, policies);
64 was_run = true;
65 }
66 63
67 private: 64 private:
68 mojo::String expected_; 65 bool value_ = false;
69 bool was_run = false; 66
67 DISALLOW_COPY_AND_ASSIGN(CheckedBoolean);
70 }; 68 };
71 69
70 void ExpectPolicyString(std::unique_ptr<CheckedBoolean> was_run,
71 mojo::String expected,
72 mojo::String policies) {
73 EXPECT_EQ(expected, policies);
74 was_run->set_value(true);
75 }
76
72 arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback( 77 arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback(
73 mojo::String expected) { 78 mojo::String expected) {
74 return arc::ArcPolicyBridge::GetPoliciesCallback( 79 std::unique_ptr<CheckedBoolean> was_run(new CheckedBoolean);
75 new PolicyStringRunnable(std::move(expected))); 80 return base::Bind(&ExpectPolicyString, base::Passed(&was_run),
81 base::Passed(&expected));
76 } 82 }
77 83
78 } // namespace 84 } // namespace
79 85
80 using testing::_; 86 using testing::_;
81 using testing::ReturnRef; 87 using testing::ReturnRef;
82 88
83 namespace arc { 89 namespace arc {
84 90
85 class ArcPolicyBridgeTest : public testing::Test { 91 class ArcPolicyBridgeTest : public testing::Test {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 TEST_F(ArcPolicyBridgeTest, PolicyInstanceUnmanagedTest) { 334 TEST_F(ArcPolicyBridgeTest, PolicyInstanceUnmanagedTest) {
329 policy_bridge()->OverrideIsManagedForTesting(false); 335 policy_bridge()->OverrideIsManagedForTesting(false);
330 policy_instance()->CallGetPolicies(PolicyStringCallback("")); 336 policy_instance()->CallGetPolicies(PolicyStringCallback(""));
331 } 337 }
332 338
333 TEST_F(ArcPolicyBridgeTest, PolicyInstanceManagedTest) { 339 TEST_F(ArcPolicyBridgeTest, PolicyInstanceManagedTest) {
334 policy_instance()->CallGetPolicies(PolicyStringCallback("{}")); 340 policy_instance()->CallGetPolicies(PolicyStringCallback("{}"));
335 } 341 }
336 342
337 } // namespace arc 343 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.cc ('k') | chrome/browser/media/router/mojo/media_router_mojo_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698