OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted_memory.h" | 5 #include "base/memory/ref_counted_memory.h" |
6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
7 #include "chrome/browser/ui/webui/theme_source.h" | 7 #include "chrome/browser/ui/webui/theme_source.h" |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "content/test/test_browser_thread.h" | 10 #include "content/test/test_browser_thread.h" |
11 #include "grit/theme_resources.h" | 11 #include "grit/theme_resources.h" |
12 #include "grit/theme_resources_standard.h" | 12 #include "grit/theme_resources_standard.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
| 15 using content::BrowserThread; |
| 16 |
15 // A mock ThemeSource (so we can override SendResponse to get at its data). | 17 // A mock ThemeSource (so we can override SendResponse to get at its data). |
16 class MockThemeSource : public ThemeSource { | 18 class MockThemeSource : public ThemeSource { |
17 public: | 19 public: |
18 explicit MockThemeSource(Profile* profile) | 20 explicit MockThemeSource(Profile* profile) |
19 : ThemeSource(profile), | 21 : ThemeSource(profile), |
20 result_request_id_(-1), | 22 result_request_id_(-1), |
21 result_data_size_(0) { | 23 result_data_size_(0) { |
22 } | 24 } |
23 | 25 |
24 virtual void SendResponse(int request_id, RefCountedMemory* data) { | 26 virtual void SendResponse(int request_id, RefCountedMemory* data) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 93 |
92 theme_source()->StartDataRequest("css/newtab.css?pie", false, 3); | 94 theme_source()->StartDataRequest("css/newtab.css?pie", false, 3); |
93 EXPECT_EQ(theme_source()->result_request_id_, 3); | 95 EXPECT_EQ(theme_source()->result_request_id_, 3); |
94 EXPECT_NE(theme_source()->result_data_size_, empty_size); | 96 EXPECT_NE(theme_source()->result_data_size_, empty_size); |
95 | 97 |
96 // Check that we send NULL back when we can't find what we're looking for. | 98 // Check that we send NULL back when we can't find what we're looking for. |
97 theme_source()->StartDataRequest("css/WRONGURL", false, 7); | 99 theme_source()->StartDataRequest("css/WRONGURL", false, 7); |
98 EXPECT_EQ(theme_source()->result_request_id_, 7); | 100 EXPECT_EQ(theme_source()->result_request_id_, 7); |
99 EXPECT_EQ(theme_source()->result_data_size_, empty_size); | 101 EXPECT_EQ(theme_source()->result_data_size_, empty_size); |
100 } | 102 } |
OLD | NEW |