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

Side by Side Diff: chrome/browser/extensions/api/sessions/sessions_apitest.cc

Issue 296003016: Fix the documentation and add Device.deviceName in sessions API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 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 "chrome/browser/extensions/api/sessions/sessions_api.h" 5 #include "chrome/browser/extensions/api/sessions/sessions_api.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 "[{\"maxResults\": 0}]", 219 "[{\"maxResults\": 0}]",
220 browser_))); 220 browser_)));
221 ASSERT_TRUE(result); 221 ASSERT_TRUE(result);
222 base::ListValue* devices = result.get(); 222 base::ListValue* devices = result.get();
223 EXPECT_EQ(5u, devices->GetSize()); 223 EXPECT_EQ(5u, devices->GetSize());
224 base::DictionaryValue* device = NULL; 224 base::DictionaryValue* device = NULL;
225 base::ListValue* sessions = NULL; 225 base::ListValue* sessions = NULL;
226 for (size_t i = 0; i < devices->GetSize(); ++i) { 226 for (size_t i = 0; i < devices->GetSize(); ++i) {
227 EXPECT_TRUE(devices->GetDictionary(i, &device)); 227 EXPECT_TRUE(devices->GetDictionary(i, &device));
228 EXPECT_EQ(kSessionTags[i], utils::GetString(device, "info")); 228 EXPECT_EQ(kSessionTags[i], utils::GetString(device, "info"));
229 EXPECT_EQ(kSessionTags[i], utils::GetString(device, "deviceName"));
229 EXPECT_TRUE(device->GetList("sessions", &sessions)); 230 EXPECT_TRUE(device->GetList("sessions", &sessions));
230 EXPECT_EQ(0u, sessions->GetSize()); 231 EXPECT_EQ(0u, sessions->GetSize());
231 } 232 }
232 } 233 }
233 234
234 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, GetDevicesMaxResults) { 235 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, GetDevicesMaxResults) {
235 CreateSessionModels(); 236 CreateSessionModels();
236 237
237 scoped_ptr<base::ListValue> result(utils::ToList( 238 scoped_ptr<base::ListValue> result(utils::ToList(
238 utils::RunFunctionAndReturnSingleResult( 239 utils::RunFunctionAndReturnSingleResult(
239 CreateFunction<SessionsGetDevicesFunction>(true).get(), 240 CreateFunction<SessionsGetDevicesFunction>(true).get(),
240 "[]", 241 "[]",
241 browser_))); 242 browser_)));
242 ASSERT_TRUE(result); 243 ASSERT_TRUE(result);
243 base::ListValue* devices = result.get(); 244 base::ListValue* devices = result.get();
244 EXPECT_EQ(5u, devices->GetSize()); 245 EXPECT_EQ(5u, devices->GetSize());
245 base::DictionaryValue* device = NULL; 246 base::DictionaryValue* device = NULL;
246 base::ListValue* sessions = NULL; 247 base::ListValue* sessions = NULL;
247 for (size_t i = 0; i < devices->GetSize(); ++i) { 248 for (size_t i = 0; i < devices->GetSize(); ++i) {
248 EXPECT_TRUE(devices->GetDictionary(i, &device)); 249 EXPECT_TRUE(devices->GetDictionary(i, &device));
249 EXPECT_EQ(kSessionTags[i], utils::GetString(device, "info")); 250 EXPECT_EQ(kSessionTags[i], utils::GetString(device, "info"));
251 EXPECT_EQ(kSessionTags[i], utils::GetString(device, "deviceName"));
250 EXPECT_TRUE(device->GetList("sessions", &sessions)); 252 EXPECT_TRUE(device->GetList("sessions", &sessions));
251 EXPECT_EQ(1u, sessions->GetSize()); 253 EXPECT_EQ(1u, sessions->GetSize());
252 } 254 }
253 } 255 }
254 256
255 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, GetDevicesListEmpty) { 257 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, GetDevicesListEmpty) {
256 scoped_ptr<base::ListValue> result(utils::ToList( 258 scoped_ptr<base::ListValue> result(utils::ToList(
257 utils::RunFunctionAndReturnSingleResult( 259 utils::RunFunctionAndReturnSingleResult(
258 CreateFunction<SessionsGetDevicesFunction>(true).get(), 260 CreateFunction<SessionsGetDevicesFunction>(true).get(),
259 "[]", 261 "[]",
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 #define MAYBE_SessionsApis SessionsApis 338 #define MAYBE_SessionsApis SessionsApis
337 #endif 339 #endif
338 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_SessionsApis) { 340 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_SessionsApis) {
339 #if defined(OS_WIN) && defined(USE_ASH) 341 #if defined(OS_WIN) && defined(USE_ASH)
340 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 342 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
341 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 343 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
342 return; 344 return;
343 #endif 345 #endif
344 346
345 ASSERT_TRUE(RunExtensionSubtest("sessions", 347 ASSERT_TRUE(RunExtensionSubtest("sessions",
346 "sessions.html")) << message_; 348 "sessions.html")) << message_;
wjywbs 2014/05/23 21:54:34 There's no test calling and checking the getDevice
not at google - send to devlin 2014/05/23 21:59:01 ok.
347 } 349 }
348 350
349 } // namespace extensions 351 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698