Implement nacl_irt_memory for non-sfi mode.
[chromium-blink-merge.git] / chrome / test / chromedriver / session_unittest.cc
blob8f0afb26496c455aa4d4d1838704075f454b4cc8
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
3 // found in the LICENSE file.
5 #include <list>
6 #include <string>
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/test/chromedriver/chrome/status.h"
10 #include "chrome/test/chromedriver/chrome/stub_chrome.h"
11 #include "chrome/test/chromedriver/chrome/stub_web_view.h"
12 #include "chrome/test/chromedriver/session.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace {
17 class MockChrome : public StubChrome {
18 public:
19 MockChrome() : web_view_("1") {}
20 virtual ~MockChrome() {}
22 virtual Status GetWebViewById(const std::string& id,
23 WebView** web_view) OVERRIDE {
24 if (id == web_view_.GetId()) {
25 *web_view = &web_view_;
26 return Status(kOk);
28 return Status(kUnknownError);
31 private:
32 StubWebView web_view_;
35 } // namespace
37 TEST(Session, GetTargetWindowNoChrome) {
38 Session session("1");
39 WebView* web_view;
40 ASSERT_EQ(kNoSuchWindow, session.GetTargetWindow(&web_view).code());
43 TEST(Session, GetTargetWindowTargetWindowClosed) {
44 scoped_ptr<Chrome> chrome(new MockChrome());
45 Session session("1", chrome.Pass());
46 session.window = "2";
47 WebView* web_view;
48 ASSERT_EQ(kNoSuchWindow, session.GetTargetWindow(&web_view).code());
51 TEST(Session, GetTargetWindowTargetWindowStillOpen) {
52 scoped_ptr<Chrome> chrome(new MockChrome());
53 Session session("1", chrome.Pass());
54 session.window = "1";
55 WebView* web_view = NULL;
56 ASSERT_EQ(kOk, session.GetTargetWindow(&web_view).code());
57 ASSERT_TRUE(web_view);