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

Unified Diff: content/browser/webui/web_ui_data_source_unittest.cc

Issue 2391073005: WebUIDataSource::AddInteger (like AddBoolean/AddString) (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.cc ('k') | content/public/browser/web_ui_data_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/webui/web_ui_data_source_unittest.cc
diff --git a/content/browser/webui/web_ui_data_source_unittest.cc b/content/browser/webui/web_ui_data_source_unittest.cc
index cf9729723ff82334ecda49f6de773d5938e40df6..fa63a996fa5dbdded3e950ac895e3aeb58737545 100644
--- a/content/browser/webui/web_ui_data_source_unittest.cc
+++ b/content/browser/webui/web_ui_data_source_unittest.cc
@@ -103,17 +103,21 @@ TEST_F(WebUIDataSourceTest, EmptyStrings) {
StartDataRequest("strings.js", base::Bind(&EmptyStringsCallback));
}
-void SomeStringsCallback(scoped_refptr<base::RefCountedMemory> data) {
+void SomeValuesCallback(scoped_refptr<base::RefCountedMemory> data) {
std::string result(data->front_as<char>(), data->size());
+ EXPECT_NE(result.find("\"flag\":true"), std::string::npos);
+ EXPECT_NE(result.find("\"counter\":10"), std::string::npos);
EXPECT_NE(result.find("\"planet\":\"pluto\""), std::string::npos);
EXPECT_NE(result.find("\"button\":\"foo\""), std::string::npos);
}
-TEST_F(WebUIDataSourceTest, SomeStrings) {
+TEST_F(WebUIDataSourceTest, SomeValues) {
source()->SetJsonPath("strings.js");
+ source()->AddBoolean("flag", true);
+ source()->AddInteger("counter", 10);
tommycli 2016/10/06 18:29:56 maybe add a test for negative values also?
michaelpg 2016/10/06 18:58:34 Done.
source()->AddString("planet", base::ASCIIToUTF16("pluto"));
source()->AddLocalizedString("button", kDummyStringId);
- StartDataRequest("strings.js", base::Bind(&SomeStringsCallback));
+ StartDataRequest("strings.js", base::Bind(&SomeValuesCallback));
}
void DefaultResourceFoobarCallback(scoped_refptr<base::RefCountedMemory> data) {
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.cc ('k') | content/public/browser/web_ui_data_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698