blob: 52bfaa2be58335e8d8609c30c55628700955ed83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/test/browser_test_utils.h"
#include "net/base/mock_host_resolver.h"
// Used to fire all of the listeners on the buttons.
static const char kScriptClickAllTestButtons[] =
"(function() {"
" setRunningAsRobot();"
" var buttons = document.getElementsByTagName('button');"
" for (var i=0; i < buttons.length; i++) {"
" buttons[i].click();"
" }"
"})();";
class ActivityLogExtensionTest : public ExtensionApiTest {
protected:
// Make sure the activity log is turned on.
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableExtensionActivityLogging);
}
};
namespace extensions {
IN_PROC_BROWSER_TEST_F(ActivityLogExtensionTest, ExtensionEndToEnd) {
host_resolver()->AddRule("*", "127.0.0.1");
StartTestServer();
// Get the extension (chrome/test/data/extensions/activity_log)
const Extension* ext =
LoadExtension(test_data_dir_.AppendASCII("activity_log"));
ASSERT_TRUE(ext);
// Open up the Options page.
ui_test_utils::NavigateToURL(
browser(),
GURL("chrome-extension://" + ext->id() + "/options.html"));
TabStripModel* tab_strip = browser()->tab_strip_model();
// Run the test by firing all the buttons. Wait until completion.
ResultCatcher catcher;
ASSERT_TRUE(content::ExecuteScript(tab_strip->GetActiveWebContents(),
kScriptClickAllTestButtons));
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
} // namespace extensions
|