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

Unified Diff: mojo/common/common_type_converters_unittest.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 years, 7 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: mojo/common/common_type_converters_unittest.cc
diff --git a/mojo/common/common_type_converters_unittest.cc b/mojo/common/common_type_converters_unittest.cc
index 438d1e76aa99823cc8b46a87d6c69bc237326d83..b291a7c29aa21bc810728461da6e4e87f8e2d40a 100644
--- a/mojo/common/common_type_converters_unittest.cc
+++ b/mojo/common/common_type_converters_unittest.cc
@@ -5,7 +5,6 @@
#include "mojo/common/common_type_converters.h"
#include "base/strings/utf_string_conversions.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
@@ -20,7 +19,7 @@ void ExpectEqualsStringPiece(const std::string& expected,
void ExpectEqualsMojoString(const std::string& expected,
const String& str) {
- EXPECT_EQ(expected, str.To<std::string>());
+ EXPECT_EQ(expected, str.get());
}
void ExpectEqualsString16(const base::string16& expected,
@@ -36,8 +35,6 @@ void ExpectEqualsMojoString(const base::string16& expected,
} // namespace
TEST(CommonTypeConvertersTest, StringPiece) {
- AllocationScope scope;
-
std::string kText("hello world");
base::StringPiece string_piece(kText);
@@ -47,17 +44,15 @@ TEST(CommonTypeConvertersTest, StringPiece) {
ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
// Test implicit construction and conversion:
- ExpectEqualsMojoString(kText, string_piece);
- ExpectEqualsStringPiece(kText, mojo_string);
+ ExpectEqualsMojoString(kText, String::From(string_piece));
+ ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
// Test null String:
- base::StringPiece empty_string_piece = String();
+ base::StringPiece empty_string_piece = String().To<base::StringPiece>();
EXPECT_TRUE(empty_string_piece.empty());
}
TEST(CommonTypeConvertersTest, String16) {
- AllocationScope scope;
-
const base::string16 string16(base::ASCIIToUTF16("hello world"));
const String mojo_string(string16);
@@ -65,11 +60,11 @@ TEST(CommonTypeConvertersTest, String16) {
EXPECT_EQ(string16, mojo_string.To<base::string16>());
// Test implicit construction and conversion:
- ExpectEqualsMojoString(string16, string16);
- ExpectEqualsString16(string16, mojo_string);
+ ExpectEqualsMojoString(string16, String::From(string16));
+ ExpectEqualsString16(string16, mojo_string.To<base::string16>());
// Test empty string conversion.
- ExpectEqualsMojoString(base::string16(), base::string16());
+ ExpectEqualsMojoString(base::string16(), String::From(base::string16()));
}
} // namespace test

Powered by Google App Engine
This is Rietveld 408576698