| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |