Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: chrome/browser/ui/webui/theme_source_unittest.cc

Issue 7465041: GTTF: Use a fresh TestingBrowserProcess for each test, part #4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: should work Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/testing_browser_process_test.h"
9 #include "chrome/test/testing_profile.h" 10 #include "chrome/test/testing_profile.h"
10 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
11 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
12 #include "grit/theme_resources_standard.h" 13 #include "grit/theme_resources_standard.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 // A mock ThemeSource (so we can override SendResponse to get at its data). 16 // A mock ThemeSource (so we can override SendResponse to get at its data).
16 class MockThemeSource : public ThemeSource { 17 class MockThemeSource : public ThemeSource {
17 public: 18 public:
18 explicit MockThemeSource(Profile* profile) 19 explicit MockThemeSource(Profile* profile)
19 : ThemeSource(profile), 20 : ThemeSource(profile),
20 result_request_id_(-1), 21 result_request_id_(-1),
21 result_data_size_(0) { 22 result_data_size_(0) {
22 } 23 }
23 24
24 virtual void SendResponse(int request_id, RefCountedMemory* data) { 25 virtual void SendResponse(int request_id, RefCountedMemory* data) {
25 result_data_size_ = data ? data->size() : 0; 26 result_data_size_ = data ? data->size() : 0;
26 result_request_id_ = request_id; 27 result_request_id_ = request_id;
27 } 28 }
28 29
29 int result_request_id_; 30 int result_request_id_;
30 size_t result_data_size_; 31 size_t result_data_size_;
31 32
32 private: 33 private:
33 ~MockThemeSource() {} 34 ~MockThemeSource() {}
34 }; 35 };
35 36
36 class WebUISourcesTest : public testing::Test { 37 class WebUISourcesTest : public TestingBrowserProcessTest {
37 public: 38 public:
38 WebUISourcesTest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {} 39 WebUISourcesTest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {}
39 40
40 TestingProfile* profile() const { return profile_.get(); } 41 TestingProfile* profile() const { return profile_.get(); }
41 MockThemeSource* theme_source() const { return theme_source_.get(); } 42 MockThemeSource* theme_source() const { return theme_source_.get(); }
42 private: 43 private:
43 virtual void SetUp() { 44 virtual void SetUp() {
44 profile_.reset(new TestingProfile()); 45 profile_.reset(new TestingProfile());
45 theme_source_ = new MockThemeSource(profile_.get()); 46 theme_source_ = new MockThemeSource(profile_.get());
46 } 47 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 theme_source()->StartDataRequest("css/newtab.css?pie", false, 3); 92 theme_source()->StartDataRequest("css/newtab.css?pie", false, 3);
92 EXPECT_EQ(theme_source()->result_request_id_, 3); 93 EXPECT_EQ(theme_source()->result_request_id_, 3);
93 EXPECT_NE(theme_source()->result_data_size_, empty_size); 94 EXPECT_NE(theme_source()->result_data_size_, empty_size);
94 95
95 // Check that we send NULL back when we can't find what we're looking for. 96 // Check that we send NULL back when we can't find what we're looking for.
96 theme_source()->StartDataRequest("css/WRONGURL", false, 7); 97 theme_source()->StartDataRequest("css/WRONGURL", false, 7);
97 EXPECT_EQ(theme_source()->result_request_id_, 7); 98 EXPECT_EQ(theme_source()->result_request_id_, 7);
98 EXPECT_EQ(theme_source()->result_data_size_, empty_size); 99 EXPECT_EQ(theme_source()->result_data_size_, empty_size);
99 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698