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

Side by Side Diff: google_apis/gcm/engine/mcs_client_unittest.cc

Issue 232113004: [GCM] Removing the mock-keychain related bool from GCMStore constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disabling the command line switches on other platforms than OS X Created 6 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
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl_unittest.cc ('k') | google_apis/gcm/gcm_client_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "google_apis/gcm/engine/mcs_client.h" 5 #include "google_apis/gcm/engine/mcs_client.h"
6 6
7 #include "base/command_line.h"
7 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "base/test/simple_test_clock.h" 12 #include "base/test/simple_test_clock.h"
12 #include "components/os_crypt/os_crypt.h" 13 #include "components/os_crypt/os_crypt_switches.h"
13 #include "google_apis/gcm/base/mcs_util.h" 14 #include "google_apis/gcm/base/mcs_util.h"
14 #include "google_apis/gcm/engine/fake_connection_factory.h" 15 #include "google_apis/gcm/engine/fake_connection_factory.h"
15 #include "google_apis/gcm/engine/fake_connection_handler.h" 16 #include "google_apis/gcm/engine/fake_connection_handler.h"
16 #include "google_apis/gcm/engine/gcm_store_impl.h" 17 #include "google_apis/gcm/engine/gcm_store_impl.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace gcm { 20 namespace gcm {
20 21
21 namespace { 22 namespace {
22 23
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 private: 79 private:
79 uint32 next_id_; 80 uint32 next_id_;
80 }; 81 };
81 82
82 class MCSClientTest : public testing::Test { 83 class MCSClientTest : public testing::Test {
83 public: 84 public:
84 MCSClientTest(); 85 MCSClientTest();
85 virtual ~MCSClientTest(); 86 virtual ~MCSClientTest();
86 87
88 virtual void SetUp() OVERRIDE;
89
87 void BuildMCSClient(); 90 void BuildMCSClient();
88 void InitializeClient(); 91 void InitializeClient();
89 void StoreCredentials(); 92 void StoreCredentials();
90 void LoginClient(const std::vector<std::string>& acknowledged_ids); 93 void LoginClient(const std::vector<std::string>& acknowledged_ids);
91 94
92 base::SimpleTestClock* clock() { return &clock_; } 95 base::SimpleTestClock* clock() { return &clock_; }
93 TestMCSClient* mcs_client() const { return mcs_client_.get(); } 96 TestMCSClient* mcs_client() const { return mcs_client_.get(); }
94 FakeConnectionFactory* connection_factory() { 97 FakeConnectionFactory* connection_factory() {
95 return &connection_factory_; 98 return &connection_factory_;
96 } 99 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 140
138 MCSClientTest::MCSClientTest() 141 MCSClientTest::MCSClientTest()
139 : run_loop_(new base::RunLoop()), 142 : run_loop_(new base::RunLoop()),
140 init_success_(true), 143 init_success_(true),
141 restored_android_id_(0), 144 restored_android_id_(0),
142 restored_security_token_(0), 145 restored_security_token_(0),
143 message_send_status_(MCSClient::SENT) { 146 message_send_status_(MCSClient::SENT) {
144 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); 147 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir());
145 run_loop_.reset(new base::RunLoop()); 148 run_loop_.reset(new base::RunLoop());
146 149
147 // On OSX, prevent the Keychain permissions popup during unit tests.
148 #if defined(OS_MACOSX)
149 OSCrypt::UseMockKeychain(true);
150 #endif
151
152 // Advance the clock to a non-zero time. 150 // Advance the clock to a non-zero time.
153 clock_.Advance(base::TimeDelta::FromSeconds(1)); 151 clock_.Advance(base::TimeDelta::FromSeconds(1));
154 } 152 }
155 153
156 MCSClientTest::~MCSClientTest() {} 154 MCSClientTest::~MCSClientTest() {}
157 155
156 void MCSClientTest::SetUp() {
157 testing::Test::SetUp();
158 #if defined(OS_MACOSX)
159 base::CommandLine::ForCurrentProcess()->AppendSwitch(
160 os_crypt::switches::kUseMockKeychain);
161 #endif // OS_MACOSX
162 }
163
158 void MCSClientTest::BuildMCSClient() { 164 void MCSClientTest::BuildMCSClient() {
159 gcm_store_.reset(new GCMStoreImpl(true, 165 gcm_store_.reset(new GCMStoreImpl(temp_directory_.path(),
160 temp_directory_.path(),
161 message_loop_.message_loop_proxy())); 166 message_loop_.message_loop_proxy()));
162 mcs_client_.reset(new TestMCSClient(&clock_, 167 mcs_client_.reset(new TestMCSClient(&clock_,
163 &connection_factory_, 168 &connection_factory_,
164 gcm_store_.get())); 169 gcm_store_.get()));
165 } 170 }
166 171
167 void MCSClientTest::InitializeClient() { 172 void MCSClientTest::InitializeClient() {
168 gcm_store_->Load(base::Bind( 173 gcm_store_->Load(base::Bind(
169 &MCSClient::Initialize, 174 &MCSClient::Initialize,
170 base::Unretained(mcs_client_.get()), 175 base::Unretained(mcs_client_.get()),
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 787
783 LoginClient(std::vector<std::string>()); 788 LoginClient(std::vector<std::string>());
784 GetFakeHandler()->ExpectOutgoingMessage(message); 789 GetFakeHandler()->ExpectOutgoingMessage(message);
785 GetFakeHandler()->ExpectOutgoingMessage(message2); 790 GetFakeHandler()->ExpectOutgoingMessage(message2);
786 PumpLoop(); 791 PumpLoop();
787 } 792 }
788 793
789 } // namespace 794 } // namespace
790 795
791 } // namespace gcm 796 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl_unittest.cc ('k') | google_apis/gcm/gcm_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698