1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* The contents of this file are subject to the Netscape Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/NPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is mozilla.org code.
15
* The Initial Developer of the Original Code is Netscape
16
* Communications Corporation. Portions created by Netscape are
17
* Copyright (C) 1998 Netscape Communications Corporation. All
21
* Chak Nanga <chak@netscape.com>
22
* David Epstein <depstein@netscape.com>
25
TestEmbed is a C++ test app based upon mfcEmbed. It includes
26
individual test cases for Embedding interface methods. Interfaces
27
covered include nsIFile & nsILocalFile, nsISHistory, nsIWebNavigation,
28
nsIWebProgressListener, nsIClipboardCommands, nsIRequest, nsIDOMWindow,
29
nsIDirectoryService, nsIProfile, nsIObserverService, nsIWebBrowser,
30
nsIWebProgress, nsIWebBrowserFind, nsIEditingSession, nsICommandManager,
31
nsICommandParams, nsIStreamListener, nsIURIContentListener,
32
nsISHistoryListener, nsIWebBrowserChrome, and nsIEmbeddingSiteWindow.
34
Individual tests also exist for methods found in nsIGlobalHistory
37
In addition to the mfcEmbed menus, it contains 5 menus: Tests,
38
Interfaces, Tools, Verified Bugs, and Clipboard Commands.
40
Executed test cases print output to a logfile called TestOutput.txt.
41
This will be created in the C:\temp folder.
43
See build instructions below.
48
1. The TestEmbedApp creates BrowserFrames
50
2. BrowserFrame creates the toolbar, statusbar, URLbar
52
BrowserFrames implement the IBrowserFrameGlue interface
53
using which new BrowserFrames can be created, statusbar
56
3. BrowserView creates the embeddable browser instance and
57
manages user interaction such as URL navigation etc.
58
BrowserView connects the BrowserImpl with the BrowserFrame
59
via the IBrowserFrameGlue interface
61
4. BrowserImpl implements the set of required/optional Gecko
65
Start by first looking at TestEmbed.cpp
70
- Includes the required Mozilla header files
73
- CWinApp derived class
74
- Creates the browser's main frame window etc
75
using the CreateNewBrowserFrame() and loads
77
- Makes the required NS_InitEmbedding() and the
78
NS_TermEmbedding() calls in the app's InitInstance()
79
and ExitInstance() functions
80
- Keeps track of the list of new BrowserFrames created
81
which it cleans up properly in ExitInstance()
84
- This is the browser's Frame window i.e. the one with the
85
"chrome" - with the toolbar, urlbar etc.
86
- Creates the toolbar, URLbar, statusbar, progressbar
87
also the browser's view window.
90
- Implements the IBrowserFrameGlue interface. This interface
91
contains platform specific implementations of functions to
92
update the statusbar, creating new browser frames etc. Embedded
93
browser's callbacks use this interface when needed
96
- Creates the embedded browser object and handles most aspects
97
of the embedded browser interactions - like URL navigation,
98
clipboard interactions etc
99
- Also has code to keep the menu/toolbar/statusbar UI items up
101
- It's the view which conntects the BrowserFrame to the BrowserImpl
102
(see below) by passing it the pointer to IBrowserFrameGlue
105
- Implements the required and/or optional embedded browser
107
(BrowserImpl.cpp implements the set of interfaces which
108
are required by Gecko of all embedding apps. The other
109
interfaces implemented in the BrowserImpl*.cpp files are
110
optional. Included in the BrowserImpl.cpp file are interface tests for nsIWebBrowserChrome,nsIEmbeddingSiteWindow, nsIStreamListener, and nsIURIContentListener.)
112
- Calls on the statusbar/progressbar update functions exposed
113
via the IBrowserFrameGlue in response to the nsIWebProgressListener
114
interface callbacks. nsIWebProgressListener methods are implemented
115
in BrowserImplWebPrgrsLstnr.cpp. nsISHistoryListener methods are
116
implemented in BrowserImplHistoryLstnr.cpp
119
- Contains dialog box code for displaying Prompts, getting
120
passwords, getting username/passwords etc
121
- Contains the CFindDialog class - used for searching text
124
winEmbedFileLocProvider.cpp, ProfilesDlg.cpp, ProfileMgr.cpp
125
- Profile management related code (by Conrad Carlen)
128
- This is where individual test cases are stored and test interfaces are
129
registered. The file is divided into three sections: 1) individual test
130
cases corresponding to the "Tests" menu. 2) tools that are helpful,
131
corresponding to the "Tools" menu. These include routines like
132
removing all entries from Global History. 3) Registration of
133
interface tests with CTests object (bottom part of the file). Example:
135
void CTests::OnInterfacesNsidomwindow()
137
CDomWindow oDomWindow(qaWebBrowser) ;
138
oDomWindow.OnStartTests(nCommandID);
141
The interface tests OnInterfacesNsidomwindow() is associated with menu
142
handlers in the message map (in top part of the file). For this example,
143
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_RUNALLTESTS, OnInterfacesNsidomwindow).
144
The test interface object (oDomWindow) is created with appropriate constructor.
145
Then the object calls the test interface's OnStartTests() method and passes
146
the selected command ID.
150
- This contains routines that are useful to QA. Such tasks as
151
printing to a logfile, displaying messages to the screen, formatting
152
output data, retrieving the name of an nsI request, and getting a urI
156
- We define "_AFXDLL" and for the compiler and specify
157
"-SUBSYSTEM:windows" for the linker using LCFLAGS and
158
LLFLAGS, respectively
159
- We also define "USE_SINGLE_SIGN_ON" to enable the
160
single sign-on support
161
- Also need REQUIRES for all modules to be included
162
- Place all .cpp files for compiling in CPPSRCS section.
164
testembed.dsp and testembed.dsw
165
- These VisualStudio workspace/project files can be used
166
to open/build this sample inside of the VC++ IDE
168
Most interface tests have their own .cpp & .h files (e.g. nsIWebBrow.cpp).
170
Instructions for building:
172
2) cd /mozilla/embedding/qa/testembed // testEmbed directory
173
3) Copy the makefile.in file and call it makefile. Place in same directory.
174
4) Change the top few lines in 'makefile' to indicate local pathway. Example:
176
topsrcdir = d:/mozilla_src/mozilla
177
srcdir = d:/mozilla_src/mozilla/embedding/qa/testembed
178
VPATH = d:/mozilla_src/mozilla/embedding/qa/testembed
179
5) cd components // components directory
180
6) Copy the makefile.in file and call it makefile. Place in same directory.
181
7) Change the top few lines in 'makefile' to indicate local pathway. Example:
183
topsrcdir = d:/mozilla_src/mozilla
184
srcdir = d:/mozilla_src/mozilla/embedding/qa/testembed/components
185
VPATH = d:/mozilla_src/mozilla/embedding/qa/testembed/components
186
8) make // compile 'makefile.in' in components
187
9) cd .. // return to testembed folder
188
10) make // compile 'makefile.in' in testembed
189
11) cd ../../../dist/bin/ // navigate to the bin dir
190
12) testembed.exe // run testEmbed.exe
192
note: if 'make' doesn't work above, try 'make -f makefile.in'
195
1) Don't run nsIWebNavigation tests after turning on the Web
196
Progress listener (from Tests menu). This will create all types
197
of listener msgs in your logfile and display many msgs on the
199
2) Best way to use web progress listener is to turn it on (from
200
the Tests menu)then change URL . Change a few more urls and
202
3) Before running nsISHistory interface tests, load 1-2 urls.
203
That will create a session history. The same applies for the
204
nsIWebNavigation interfaces tests. One loaded url will enable
205
back/forward navigation.
206
4) nsIUriContentListener is registered from the "Tests" >
207
"Add urIContentListener" menu. There are submenu items for different options.