OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/ref_counted_memory.h" | 6 #include "base/memory/ref_counted_memory.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/webui/web_ui_data_source_impl.h" | 8 #include "content/browser/webui/web_ui_data_source_impl.h" |
9 #include "content/public/test/test_browser_thread_bundle.h" | 9 #include "content/public/test/test_browser_thread_bundle.h" |
10 #include "content/test/test_content_client.h" | 10 #include "content/test/test_content_client.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 TestBrowserThreadBundle thread_bundle_; | 87 TestBrowserThreadBundle thread_bundle_; |
88 scoped_refptr<WebUIDataSourceImpl> source_; | 88 scoped_refptr<WebUIDataSourceImpl> source_; |
89 TestClient client_; | 89 TestClient client_; |
90 }; | 90 }; |
91 | 91 |
92 TEST_F(WebUIDataSourceTest, EmptyStrings) { | 92 TEST_F(WebUIDataSourceTest, EmptyStrings) { |
93 source()->SetJsonPath("strings.js"); | 93 source()->SetJsonPath("strings.js"); |
94 StartDataRequest("strings.js"); | 94 StartDataRequest("strings.js"); |
95 std::string result(result_data_->front_as<char>(), result_data_->size()); | 95 std::string result(result_data_->front_as<char>(), result_data_->size()); |
96 EXPECT_NE(result.find("var templateData = {"), std::string::npos); | 96 EXPECT_NE(result.find("loadTimeData.data = {"), std::string::npos); |
97 EXPECT_NE(result.find("};"), std::string::npos); | 97 EXPECT_NE(result.find("};"), std::string::npos); |
98 } | 98 } |
99 | 99 |
100 TEST_F(WebUIDataSourceTest, SomeStrings) { | 100 TEST_F(WebUIDataSourceTest, SomeStrings) { |
101 source()->SetJsonPath("strings.js"); | 101 source()->SetJsonPath("strings.js"); |
102 source()->AddString("planet", base::ASCIIToUTF16("pluto")); | 102 source()->AddString("planet", base::ASCIIToUTF16("pluto")); |
103 source()->AddLocalizedString("button", kDummyStringId); | 103 source()->AddLocalizedString("button", kDummyStringId); |
104 StartDataRequest("strings.js"); | 104 StartDataRequest("strings.js"); |
105 std::string result(result_data_->front_as<char>(), result_data_->size()); | 105 std::string result(result_data_->front_as<char>(), result_data_->size()); |
106 EXPECT_NE(result.find("\"planet\":\"pluto\""), std::string::npos); | 106 EXPECT_NE(result.find("\"planet\":\"pluto\""), std::string::npos); |
(...skipping 28 matching lines...) Expand all Loading... |
135 EXPECT_EQ(GetMimeType("foo"), html); | 135 EXPECT_EQ(GetMimeType("foo"), html); |
136 EXPECT_EQ(GetMimeType("foo.html"), html); | 136 EXPECT_EQ(GetMimeType("foo.html"), html); |
137 EXPECT_EQ(GetMimeType(".js"), js); | 137 EXPECT_EQ(GetMimeType(".js"), js); |
138 EXPECT_EQ(GetMimeType("foo.js"), js); | 138 EXPECT_EQ(GetMimeType("foo.js"), js); |
139 EXPECT_EQ(GetMimeType("js"), html); | 139 EXPECT_EQ(GetMimeType("js"), html); |
140 EXPECT_EQ(GetMimeType("foojs"), html); | 140 EXPECT_EQ(GetMimeType("foojs"), html); |
141 EXPECT_EQ(GetMimeType("foo.jsp"), html); | 141 EXPECT_EQ(GetMimeType("foo.jsp"), html); |
142 } | 142 } |
143 | 143 |
144 } // namespace content | 144 } // namespace content |
OLD | NEW |