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/test/test_content_client.h" | 10 #include "content/test/test_content_client.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 namespace { | 14 namespace { |
14 | 15 |
15 const int kDummyStringId = 123; | 16 const int kDummyStringId = 123; |
16 const int kDummyDefaultResourceId = 456; | 17 const int kDummyDefaultResourceId = 456; |
17 const int kDummyResourceId = 789; | 18 const int kDummyResourceId = 789; |
18 | 19 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 source); | 77 source); |
77 source_impl->disable_set_font_strings_for_testing(); | 78 source_impl->disable_set_font_strings_for_testing(); |
78 source_ = make_scoped_refptr(source_impl); | 79 source_ = make_scoped_refptr(source_impl); |
79 } | 80 } |
80 | 81 |
81 // Store response for later comparisons. | 82 // Store response for later comparisons. |
82 void SendResult(base::RefCountedMemory* data) { | 83 void SendResult(base::RefCountedMemory* data) { |
83 result_data_ = data; | 84 result_data_ = data; |
84 } | 85 } |
85 | 86 |
| 87 TestBrowserThreadBundle thread_bundle_; |
86 scoped_refptr<WebUIDataSourceImpl> source_; | 88 scoped_refptr<WebUIDataSourceImpl> source_; |
87 TestClient client_; | 89 TestClient client_; |
88 }; | 90 }; |
89 | 91 |
90 TEST_F(WebUIDataSourceTest, EmptyStrings) { | 92 TEST_F(WebUIDataSourceTest, EmptyStrings) { |
91 source()->SetJsonPath("strings.js"); | 93 source()->SetJsonPath("strings.js"); |
92 StartDataRequest("strings.js"); | 94 StartDataRequest("strings.js"); |
93 std::string result(result_data_->front_as<char>(), result_data_->size()); | 95 std::string result(result_data_->front_as<char>(), result_data_->size()); |
94 EXPECT_NE(result.find("var templateData = {"), std::string::npos); | 96 EXPECT_NE(result.find("var templateData = {"), std::string::npos); |
95 EXPECT_NE(result.find("};"), std::string::npos); | 97 EXPECT_NE(result.find("};"), std::string::npos); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 EXPECT_EQ(GetMimeType("foo"), html); | 135 EXPECT_EQ(GetMimeType("foo"), html); |
134 EXPECT_EQ(GetMimeType("foo.html"), html); | 136 EXPECT_EQ(GetMimeType("foo.html"), html); |
135 EXPECT_EQ(GetMimeType(".js"), js); | 137 EXPECT_EQ(GetMimeType(".js"), js); |
136 EXPECT_EQ(GetMimeType("foo.js"), js); | 138 EXPECT_EQ(GetMimeType("foo.js"), js); |
137 EXPECT_EQ(GetMimeType("js"), html); | 139 EXPECT_EQ(GetMimeType("js"), html); |
138 EXPECT_EQ(GetMimeType("foojs"), html); | 140 EXPECT_EQ(GetMimeType("foojs"), html); |
139 EXPECT_EQ(GetMimeType("foo.jsp"), html); | 141 EXPECT_EQ(GetMimeType("foo.jsp"), html); |
140 } | 142 } |
141 | 143 |
142 } // namespace content | 144 } // namespace content |
OLD | NEW |