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

Side by Side Diff: chrome/browser/extensions/api/gcm/gcm_apitest.cc

Issue 132293003: [GCM] Disable some GCM API tests on offical window bots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | 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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "chrome/browser/extensions/api/gcm/gcm_api.h" 6 #include "chrome/browser/extensions/api/gcm/gcm_api.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 9 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
11 #include "chrome/common/extensions/features/feature_channel.h" 11 #include "chrome/common/extensions/features/feature_channel.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 13
14 namespace { 14 namespace {
15 15
16 const char kEventsExtension[] = "gcm/events"; 16 const char kEventsExtension[] = "gcm/events";
17 17
18 } // namespace 18 } // namespace
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 class GcmApiTest : public ExtensionApiTest { 22 class GcmApiTest : public ExtensionApiTest {
23 public: 23 public:
24 GcmApiTest() : fake_gcm_profile_service_(NULL) {} 24 GcmApiTest() : fake_gcm_profile_service_(NULL) {}
25 25
26 protected: 26 protected:
27 virtual void SetUp() OVERRIDE;
28 virtual void SetUpOnMainThread() OVERRIDE; 27 virtual void SetUpOnMainThread() OVERRIDE;
29 28
30 void StartCollecting(); 29 void StartCollecting();
31 30
32 const Extension* LoadTestExtension(const std::string& extension_path, 31 const Extension* LoadTestExtension(const std::string& extension_path,
33 const std::string& page_name); 32 const std::string& page_name);
34 33
35 gcm::FakeGCMProfileService* service() const; 34 gcm::FakeGCMProfileService* service() const;
35 bool ShouldSkipTest() const;
36 36
37 private: 37 private:
38 gcm::FakeGCMProfileService* fake_gcm_profile_service_; 38 gcm::FakeGCMProfileService* fake_gcm_profile_service_;
39 }; 39 };
40 40
41 void GcmApiTest::SetUp() {
42 // TODO(jianli): Once the GCM API enters stable, remove |channel|.
43 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_UNKNOWN);
44
45 ExtensionApiTest::SetUp();
46 }
47
48 void GcmApiTest::SetUpOnMainThread() { 41 void GcmApiTest::SetUpOnMainThread() {
49 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory( 42 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory(
50 browser()->profile(), &gcm::FakeGCMProfileService::Build); 43 browser()->profile(), &gcm::FakeGCMProfileService::Build);
51 fake_gcm_profile_service_ = static_cast<gcm::FakeGCMProfileService*>( 44 fake_gcm_profile_service_ = static_cast<gcm::FakeGCMProfileService*>(
52 gcm::GCMProfileServiceFactory::GetInstance()->GetForProfile( 45 gcm::GCMProfileServiceFactory::GetInstance()->GetForProfile(
53 browser()->profile())); 46 browser()->profile()));
54 gcm::FakeGCMProfileService::EnableGCMForTesting(); 47 gcm::FakeGCMProfileService::EnableGCMForTesting();
55 } 48 }
56 49
57 void GcmApiTest::StartCollecting() { 50 void GcmApiTest::StartCollecting() {
58 service()->set_collect(true); 51 service()->set_collect(true);
59 } 52 }
60 53
61 gcm::FakeGCMProfileService* GcmApiTest::service() const { 54 gcm::FakeGCMProfileService* GcmApiTest::service() const {
62 return fake_gcm_profile_service_; 55 return fake_gcm_profile_service_;
63 } 56 }
64 57
65 const Extension* GcmApiTest::LoadTestExtension( 58 const Extension* GcmApiTest::LoadTestExtension(
66 const std::string& extension_path, 59 const std::string& extension_path,
67 const std::string& page_name) { 60 const std::string& page_name) {
61 // TODO(jianli): Once the GCM API enters stable, remove |channel|.
62 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_UNKNOWN);
63
68 const Extension* extension = 64 const Extension* extension =
69 LoadExtension(test_data_dir_.AppendASCII(extension_path)); 65 LoadExtension(test_data_dir_.AppendASCII(extension_path));
70 if (extension) { 66 if (extension) {
71 ui_test_utils::NavigateToURL( 67 ui_test_utils::NavigateToURL(
72 browser(), extension->GetResourceURL(page_name)); 68 browser(), extension->GetResourceURL(page_name));
73 } 69 }
74 return extension; 70 return extension;
75 } 71 }
76 72
73 bool GcmApiTest::ShouldSkipTest() const {
74 // TODO(jianli): Remove this once the GCM API enters stable.
75 #if defined(OS_WIN)
76 return chrome::VersionInfo::GetChannel() ==
77 chrome::VersionInfo::CHANNEL_STABLE;
78 #else
79 return false;
80 #endif
81 }
82
77 IN_PROC_BROWSER_TEST_F(GcmApiTest, RegisterValidation) { 83 IN_PROC_BROWSER_TEST_F(GcmApiTest, RegisterValidation) {
84 if (ShouldSkipTest())
85 return;
86
78 ASSERT_TRUE(RunExtensionTest("gcm/functions/register_validation")); 87 ASSERT_TRUE(RunExtensionTest("gcm/functions/register_validation"));
79 } 88 }
80 89
81 IN_PROC_BROWSER_TEST_F(GcmApiTest, Register) { 90 IN_PROC_BROWSER_TEST_F(GcmApiTest, Register) {
91 if (ShouldSkipTest())
92 return;
93
82 StartCollecting(); 94 StartCollecting();
83 ASSERT_TRUE(RunExtensionTest("gcm/functions/register")); 95 ASSERT_TRUE(RunExtensionTest("gcm/functions/register"));
84 96
85 // SHA1 of the public key provided in manifest.json. 97 // SHA1 of the public key provided in manifest.json.
86 EXPECT_EQ("26469186F238EE08FA71C38311C6990F61D40DCA", 98 EXPECT_EQ("26469186F238EE08FA71C38311C6990F61D40DCA",
87 service()->last_registered_cert()); 99 service()->last_registered_cert());
88 const std::vector<std::string>& sender_ids = 100 const std::vector<std::string>& sender_ids =
89 service()->last_registered_sender_ids(); 101 service()->last_registered_sender_ids();
90 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender1") != 102 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender1") !=
91 sender_ids.end()); 103 sender_ids.end());
92 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender2") != 104 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender2") !=
93 sender_ids.end()); 105 sender_ids.end());
94 } 106 }
95 107
96 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendValidation) { 108 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendValidation) {
109 if (ShouldSkipTest())
110 return;
111
97 ASSERT_TRUE(RunExtensionTest("gcm/functions/send")); 112 ASSERT_TRUE(RunExtensionTest("gcm/functions/send"));
98 } 113 }
99 114
100 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendMessageData) { 115 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendMessageData) {
116 if (ShouldSkipTest())
117 return;
118
101 StartCollecting(); 119 StartCollecting();
102 ASSERT_TRUE(RunExtensionTest("gcm/functions/send_message_data")); 120 ASSERT_TRUE(RunExtensionTest("gcm/functions/send_message_data"));
103 121
104 EXPECT_EQ("destination-id", service()->last_receiver_id()); 122 EXPECT_EQ("destination-id", service()->last_receiver_id());
105 const gcm::GCMClient::OutgoingMessage& message = 123 const gcm::GCMClient::OutgoingMessage& message =
106 service()->last_sent_message(); 124 service()->last_sent_message();
107 gcm::GCMClient::MessageData::const_iterator iter; 125 gcm::GCMClient::MessageData::const_iterator iter;
108 126
109 EXPECT_TRUE((iter = message.data.find("key1")) != message.data.end()); 127 EXPECT_TRUE((iter = message.data.find("key1")) != message.data.end());
110 EXPECT_EQ("value1", iter->second); 128 EXPECT_EQ("value1", iter->second);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 gcm::GCMClient::NETWORK_ERROR); 179 gcm::GCMClient::NETWORK_ERROR);
162 router.OnSendError(extension->id(), "error_message_4", 180 router.OnSendError(extension->id(), "error_message_4",
163 gcm::GCMClient::UNKNOWN_ERROR); 181 gcm::GCMClient::UNKNOWN_ERROR);
164 router.OnSendError(extension->id(), "error_message_5", 182 router.OnSendError(extension->id(), "error_message_5",
165 gcm::GCMClient::TTL_EXCEEDED); 183 gcm::GCMClient::TTL_EXCEEDED);
166 184
167 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 185 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
168 } 186 }
169 187
170 } // namespace extensions 188 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698