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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 namespace { | 14 namespace { |
15 | 15 |
16 const int kDummyStringId = 123; | 16 const int kDummyStringId = 123; |
17 const int kDummyDefaultResourceId = 456; | 17 const int kDummyDefaultResourceId = 456; |
18 const int kDummyResourceId = 789; | 18 const int kDummyResourceId = 789; |
19 | 19 |
20 const char kDummyString[] = "foo"; | 20 const char kDummyString[] = "foo"; |
21 const char kDummyDefaultResource[] = "<html>foo</html>"; | 21 const char kDummyDefaultResource[] = "<html>foo</html>"; |
22 const char kDummytResource[] = "<html>blah</html>"; | 22 const char kDummytResource[] = "<html>blah</html>"; |
23 | 23 |
24 class TestClient : public TestContentClient { | 24 class TestClient : public TestContentClient { |
25 public: | 25 public: |
26 TestClient() {} | 26 TestClient() {} |
27 virtual ~TestClient() {} | 27 virtual ~TestClient() {} |
28 | 28 |
29 virtual base::string16 GetLocalizedString(int message_id) const OVERRIDE { | 29 virtual base::string16 GetLocalizedString(int message_id) const override { |
30 if (message_id == kDummyStringId) | 30 if (message_id == kDummyStringId) |
31 return base::UTF8ToUTF16(kDummyString); | 31 return base::UTF8ToUTF16(kDummyString); |
32 return base::string16(); | 32 return base::string16(); |
33 | 33 |
34 } | 34 } |
35 | 35 |
36 virtual base::RefCountedStaticMemory* GetDataResourceBytes( | 36 virtual base::RefCountedStaticMemory* GetDataResourceBytes( |
37 int resource_id) const OVERRIDE { | 37 int resource_id) const override { |
38 base::RefCountedStaticMemory* bytes = NULL; | 38 base::RefCountedStaticMemory* bytes = NULL; |
39 if (resource_id == kDummyDefaultResourceId) { | 39 if (resource_id == kDummyDefaultResourceId) { |
40 bytes = new base::RefCountedStaticMemory( | 40 bytes = new base::RefCountedStaticMemory( |
41 kDummyDefaultResource, arraysize(kDummyDefaultResource)); | 41 kDummyDefaultResource, arraysize(kDummyDefaultResource)); |
42 } else if (resource_id == kDummyResourceId) { | 42 } else if (resource_id == kDummyResourceId) { |
43 bytes = new base::RefCountedStaticMemory( | 43 bytes = new base::RefCountedStaticMemory( |
44 kDummytResource, arraysize(kDummytResource)); | 44 kDummytResource, arraysize(kDummytResource)); |
45 } | 45 } |
46 return bytes; | 46 return bytes; |
47 } | 47 } |
(...skipping 87 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 |