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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
diff --git a/chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc b/chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
index fa7216d1bf091735fad31bcab56c4055f412bb73..139333ab345f67ca87238ca00af19ec96548738e 100644
--- a/chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
+++ b/chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
@@ -51,28 +51,34 @@ char kFakeONC[] =
"\"GUID\":\"{00f79111-51e0-e6e0-76b3b55450d80a1b}\"}"
"]}";
-// Helper class to define the PolicyStringCallback that expects to be called
-// at least once and that expects a given string as parameter.
-class PolicyStringRunnable
- : public arc::ArcPolicyBridge::GetPoliciesCallback::Runnable {
+// Helper class to define a PolicyStringCallback which verifies that it was run.
+// Wraps a bool initially set to |false| and verifies that it's been set to
+// |true| before destruction.
+class CheckedBoolean {
public:
- explicit PolicyStringRunnable(mojo::String expected)
- : expected_(std::move(expected)) {}
- ~PolicyStringRunnable() override { EXPECT_TRUE(was_run); }
- void Run(const mojo::String& policies) override {
- EXPECT_EQ(expected_, policies);
- was_run = true;
- }
+ CheckedBoolean() {}
+ ~CheckedBoolean() { EXPECT_TRUE(value_); }
+
+ void set_value(bool value) { value_ = value; }
private:
- mojo::String expected_;
- bool was_run = false;
+ bool value_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(CheckedBoolean);
};
+void ExpectPolicyString(std::unique_ptr<CheckedBoolean> was_run,
+ mojo::String expected,
+ mojo::String policies) {
+ EXPECT_EQ(expected, policies);
+ was_run->set_value(true);
+}
+
arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback(
mojo::String expected) {
- return arc::ArcPolicyBridge::GetPoliciesCallback(
- new PolicyStringRunnable(std::move(expected)));
+ std::unique_ptr<CheckedBoolean> was_run(new CheckedBoolean);
+ return base::Bind(&ExpectPolicyString, base::Passed(&was_run),
+ base::Passed(&expected));
}
} // namespace
« 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