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/test/chromedriver/session_unittest.cc

Issue 19616008: [chromedriver] Allow commands to be async. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <list> 5 #include <list>
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/lock.h"
11 #include "chrome/test/chromedriver/chrome/status.h" 9 #include "chrome/test/chromedriver/chrome/status.h"
12 #include "chrome/test/chromedriver/chrome/stub_chrome.h" 10 #include "chrome/test/chromedriver/chrome/stub_chrome.h"
13 #include "chrome/test/chromedriver/chrome/stub_web_view.h" 11 #include "chrome/test/chromedriver/chrome/stub_web_view.h"
14 #include "chrome/test/chromedriver/session.h" 12 #include "chrome/test/chromedriver/session.h"
15 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
16 14
17 TEST(SessionAccessorTest, LocksSession) {
18 scoped_ptr<Session> scoped_session(new Session("id"));
19 Session* session = scoped_session.get();
20 scoped_refptr<SessionAccessor> accessor(
21 new SessionAccessorImpl(scoped_session.Pass()));
22 scoped_ptr<base::AutoLock> lock;
23 ASSERT_EQ(session, accessor->Access(&lock));
24 ASSERT_TRUE(lock.get());
25 }
26
27 namespace { 15 namespace {
28 16
29 class MockChrome : public StubChrome { 17 class MockChrome : public StubChrome {
30 public: 18 public:
31 MockChrome() : web_view_("1") {} 19 MockChrome() : web_view_("1") {}
32 virtual ~MockChrome() {} 20 virtual ~MockChrome() {}
33 21
34 virtual Status GetWebViewById(const std::string& id, 22 virtual Status GetWebViewById(const std::string& id,
35 WebView** web_view) OVERRIDE { 23 WebView** web_view) OVERRIDE {
36 if (id == web_view_.GetId()) { 24 if (id == web_view_.GetId()) {
(...skipping 24 matching lines...) Expand all
61 } 49 }
62 50
63 TEST(Session, GetTargetWindowTargetWindowStillOpen) { 51 TEST(Session, GetTargetWindowTargetWindowStillOpen) {
64 scoped_ptr<Chrome> chrome(new MockChrome()); 52 scoped_ptr<Chrome> chrome(new MockChrome());
65 Session session("1", chrome.Pass()); 53 Session session("1", chrome.Pass());
66 session.window = "1"; 54 session.window = "1";
67 WebView* web_view = NULL; 55 WebView* web_view = NULL;
68 ASSERT_EQ(kOk, session.GetTargetWindow(&web_view).code()); 56 ASSERT_EQ(kOk, session.GetTargetWindow(&web_view).code());
69 ASSERT_TRUE(web_view); 57 ASSERT_TRUE(web_view);
70 } 58 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/session_thread_map.h ('k') | chrome/test/chromedriver/synchronized_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698