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

Side by Side Diff: google_apis/gcm/engine/gcm_store_impl_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: Removing unnecessary changes 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gcm_store_impl.h" 5 #include "google_apis/gcm/engine/gcm_store_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
17 #include "google_apis/gcm/base/mcs_message.h" 18 #include "google_apis/gcm/base/mcs_message.h"
18 #include "google_apis/gcm/base/mcs_util.h" 19 #include "google_apis/gcm/base/mcs_util.h"
19 #include "google_apis/gcm/protocol/mcs.pb.h" 20 #include "google_apis/gcm/protocol/mcs.pb.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 15 matching lines...) Expand all
36 const char kCategoryName[] = "my_category"; 37 const char kCategoryName[] = "my_category";
37 38
38 const uint64 kDeviceId = 22; 39 const uint64 kDeviceId = 22;
39 const uint64 kDeviceToken = 55; 40 const uint64 kDeviceToken = 55;
40 41
41 class GCMStoreImplTest : public testing::Test { 42 class GCMStoreImplTest : public testing::Test {
42 public: 43 public:
43 GCMStoreImplTest(); 44 GCMStoreImplTest();
44 virtual ~GCMStoreImplTest(); 45 virtual ~GCMStoreImplTest();
45 46
47 virtual void SetUp() OVERRIDE;
48
46 scoped_ptr<GCMStore> BuildGCMStore(); 49 scoped_ptr<GCMStore> BuildGCMStore();
47 50
48 std::string GetNextPersistentId(); 51 std::string GetNextPersistentId();
49 52
50 void PumpLoop(); 53 void PumpLoop();
51 54
52 void LoadCallback(scoped_ptr<GCMStore::LoadResult>* result_dst, 55 void LoadCallback(scoped_ptr<GCMStore::LoadResult>* result_dst,
53 scoped_ptr<GCMStore::LoadResult> result); 56 scoped_ptr<GCMStore::LoadResult> result);
54 void UpdateCallback(bool success); 57 void UpdateCallback(bool success);
55 58
56 protected: 59 protected:
57 base::MessageLoop message_loop_; 60 base::MessageLoop message_loop_;
58 base::ScopedTempDir temp_directory_; 61 base::ScopedTempDir temp_directory_;
59 bool expected_success_; 62 bool expected_success_;
60 uint64 next_persistent_id_; 63 uint64 next_persistent_id_;
61 scoped_ptr<base::RunLoop> run_loop_; 64 scoped_ptr<base::RunLoop> run_loop_;
62 }; 65 };
63 66
64 GCMStoreImplTest::GCMStoreImplTest() 67 GCMStoreImplTest::GCMStoreImplTest()
65 : expected_success_(true), 68 : expected_success_(true),
66 next_persistent_id_(base::Time::Now().ToInternalValue()) { 69 next_persistent_id_(base::Time::Now().ToInternalValue()) {
67 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); 70 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir());
68 run_loop_.reset(new base::RunLoop()); 71 run_loop_.reset(new base::RunLoop());
69 } 72 }
70 73
71 GCMStoreImplTest::~GCMStoreImplTest() {} 74 GCMStoreImplTest::~GCMStoreImplTest() {}
72 75
76 void GCMStoreImplTest::SetUp() {
77 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-mock-keychain");
jianli 2014/04/10 18:38:12 better call testing::Test::SetUp();
Nicolas Zea 2014/04/10 18:54:48 That's not necessary, it doesn't do anything. Over
fgorski 2014/04/10 19:01:15 Putting both in (in all 3 files)
78 }
79
73 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() { 80 scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() {
74 return scoped_ptr<GCMStore>(new GCMStoreImpl( 81 return scoped_ptr<GCMStore>(new GCMStoreImpl(
75 true,
76 temp_directory_.path(), 82 temp_directory_.path(),
77 message_loop_.message_loop_proxy())); 83 message_loop_.message_loop_proxy()));
78 } 84 }
79 85
80 std::string GCMStoreImplTest::GetNextPersistentId() { 86 std::string GCMStoreImplTest::GetNextPersistentId() {
81 return base::Uint64ToString(next_persistent_id_++); 87 return base::Uint64ToString(next_persistent_id_++);
82 } 88 }
83 89
84 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); } 90 void GCMStoreImplTest::PumpLoop() { message_loop_.RunUntilIdle(); }
85 91
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 493
488 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, 494 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback,
489 base::Unretained(this), 495 base::Unretained(this),
490 &load_result)); 496 &load_result));
491 PumpLoop(); 497 PumpLoop();
492 } 498 }
493 499
494 } // namespace 500 } // namespace
495 501
496 } // namespace gcm 502 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698