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

Side by Side Diff: components/feedback/feedback_uploader_chrome_unittest.cc

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/feedback/feedback_uploader_chrome.h" 5 #include "components/feedback/feedback_uploader_chrome.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
12 #include "components/variations/variations_associated_data.h" 11 #include "components/variations/variations_associated_data.h"
13 #include "components/variations/variations_http_header_provider.h" 12 #include "components/variations/variations_http_header_provider.h"
14 #include "content/public/test/test_browser_context.h" 13 #include "content/public/test/test_browser_context.h"
14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "net/url_request/test_url_fetcher_factory.h" 15 #include "net/url_request/test_url_fetcher_factory.h"
16 #include "net/url_request/url_fetcher_delegate.h" 16 #include "net/url_request/url_fetcher_delegate.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace feedback { 19 namespace feedback {
20 20
21 class FeedbackUploaderChromeTest : public ::testing::Test { 21 class FeedbackUploaderChromeTest : public ::testing::Test {
22 protected: 22 protected:
23 FeedbackUploaderChromeTest() {} 23 FeedbackUploaderChromeTest()
24 : browser_thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
24 25
25 ~FeedbackUploaderChromeTest() override { 26 ~FeedbackUploaderChromeTest() override {
26 // Clean up registered ids. 27 // Clean up registered ids.
27 variations::testing::ClearAllVariationIDs(); 28 variations::testing::ClearAllVariationIDs();
28 } 29 }
29 30
30 // Registers a field trial with the specified name and group and an associated 31 // Registers a field trial with the specified name and group and an associated
31 // google web property variation id. 32 // google web property variation id.
32 void CreateFieldTrialWithId(const std::string& trial_name, 33 void CreateFieldTrialWithId(const std::string& trial_name,
33 const std::string& group_name, 34 const std::string& group_name,
34 int variation_id) { 35 int variation_id) {
35 variations::AssociateGoogleVariationID( 36 variations::AssociateGoogleVariationID(
36 variations::GOOGLE_WEB_PROPERTIES, trial_name, group_name, 37 variations::GOOGLE_WEB_PROPERTIES, trial_name, group_name,
37 static_cast<variations::VariationID>(variation_id)); 38 static_cast<variations::VariationID>(variation_id));
38 base::FieldTrialList::CreateFieldTrial(trial_name, group_name)->group(); 39 base::FieldTrialList::CreateFieldTrial(trial_name, group_name)->group();
39 } 40 }
40 41
41 private: 42 private:
42 base::MessageLoopForUI message_loop_; 43 content::TestBrowserThreadBundle browser_thread_bundle_;
43 44
44 DISALLOW_COPY_AND_ASSIGN(FeedbackUploaderChromeTest); 45 DISALLOW_COPY_AND_ASSIGN(FeedbackUploaderChromeTest);
45 }; 46 };
46 47
47 TEST_F(FeedbackUploaderChromeTest, VariationHeaders) { 48 TEST_F(FeedbackUploaderChromeTest, VariationHeaders) {
48 // Register a trial and variation id, so that there is data in variations 49 // Register a trial and variation id, so that there is data in variations
49 // headers. Also, the variations header provider may have been registered to 50 // headers. Also, the variations header provider may have been registered to
50 // observe some other field trial list, so reset it. 51 // observe some other field trial list, so reset it.
51 variations::VariationsHttpHeaderProvider::GetInstance()->ResetForTesting(); 52 variations::VariationsHttpHeaderProvider::GetInstance()->ResetForTesting();
52 base::FieldTrialList field_trial_list_(NULL); 53 base::FieldTrialList field_trial_list_(NULL);
(...skipping 11 matching lines...) Expand all
64 std::string value; 65 std::string value;
65 EXPECT_TRUE(headers.GetHeader("X-Client-Data", &value)); 66 EXPECT_TRUE(headers.GetHeader("X-Client-Data", &value));
66 EXPECT_FALSE(value.empty()); 67 EXPECT_FALSE(value.empty());
67 // The fetcher's delegate is responsible for freeing the fetcher (and itself). 68 // The fetcher's delegate is responsible for freeing the fetcher (and itself).
68 fetcher->delegate()->OnURLFetchComplete(fetcher); 69 fetcher->delegate()->OnURLFetchComplete(fetcher);
69 70
70 variations::VariationsHttpHeaderProvider::GetInstance()->ResetForTesting(); 71 variations::VariationsHttpHeaderProvider::GetInstance()->ResetForTesting();
71 } 72 }
72 73
73 } // namespace feedback 74 } // namespace feedback
OLDNEW
« no previous file with comments | « components/feedback/feedback_uploader_chrome.cc ('k') | components/precache/content/precache_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698