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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 return bytes; | 46 return bytes; |
47 } | 47 } |
48 }; | 48 }; |
49 | 49 |
50 } | 50 } |
51 | 51 |
52 class WebUIDataSourceTest : public testing::Test { | 52 class WebUIDataSourceTest : public testing::Test { |
53 public: | 53 public: |
54 WebUIDataSourceTest() : result_data_(NULL) {} | 54 WebUIDataSourceTest() : result_data_(NULL) {} |
55 virtual ~WebUIDataSourceTest() {} | 55 ~WebUIDataSourceTest() override {} |
56 WebUIDataSourceImpl* source() { return source_.get(); } | 56 WebUIDataSourceImpl* source() { return source_.get(); } |
57 | 57 |
58 void StartDataRequest(const std::string& path) { | 58 void StartDataRequest(const std::string& path) { |
59 source_->StartDataRequest( | 59 source_->StartDataRequest( |
60 path, | 60 path, |
61 0, 0, | 61 0, 0, |
62 base::Bind(&WebUIDataSourceTest::SendResult, | 62 base::Bind(&WebUIDataSourceTest::SendResult, |
63 base::Unretained(this))); | 63 base::Unretained(this))); |
64 } | 64 } |
65 | 65 |
66 std::string GetMimeType(const std::string& path) const { | 66 std::string GetMimeType(const std::string& path) const { |
67 return source_->GetMimeType(path); | 67 return source_->GetMimeType(path); |
68 } | 68 } |
69 | 69 |
70 scoped_refptr<base::RefCountedMemory> result_data_; | 70 scoped_refptr<base::RefCountedMemory> result_data_; |
71 | 71 |
72 private: | 72 private: |
73 virtual void SetUp() { | 73 void SetUp() override { |
74 SetContentClient(&client_); | 74 SetContentClient(&client_); |
75 WebUIDataSource* source = WebUIDataSourceImpl::Create("host"); | 75 WebUIDataSource* source = WebUIDataSourceImpl::Create("host"); |
76 WebUIDataSourceImpl* source_impl = static_cast<WebUIDataSourceImpl*>( | 76 WebUIDataSourceImpl* source_impl = static_cast<WebUIDataSourceImpl*>( |
77 source); | 77 source); |
78 source_impl->disable_set_font_strings_for_testing(); | 78 source_impl->disable_set_font_strings_for_testing(); |
79 source_ = make_scoped_refptr(source_impl); | 79 source_ = make_scoped_refptr(source_impl); |
80 } | 80 } |
81 | 81 |
82 // Store response for later comparisons. | 82 // Store response for later comparisons. |
83 void SendResult(base::RefCountedMemory* data) { | 83 void SendResult(base::RefCountedMemory* data) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |